GithubHelp home page GithubHelp logo

lingprog-graph's Introduction

Weighted graph analysis

1. Introduction

This is a small CLI application which performs some operations over a weighted graph, such as:

  • Number of vertices (nodes)
  • Number of edges
  • List all vertices
  • Shortest path between two vertices
  • Graph diameter
  • Vertex with maximum degree centrality
  • Vertex with maximum betweenness centrality

Developed by Mario Simão for the Programming Languages class, during the Computer and Electronic Engineering course at the Federal University of Rio de Janeiro (UFRJ).

2. Compilation

$ make all

3. Usage

$ ./graph <command> [<args>]

The available commands are listed below.

3.1. help

Displays information about all commands.

$ ./graph help

3.2. number

Number of edges and vertices.

$ ./graph number <filename>

3.3. vertices

List all vertices.

$ ./graph vertices <filename>

3.4. path

Shortest path between source and target vertices

$ ./graph vertices <filename> <source> <target>

3.5. diameter

Graph diameter (longest path between all shortest paths).

$ ./graph diameter <filename>

3.6. degree

Vertex with maximum degree centrality.

$ ./graph diameter <filename>

3.7. betweenness

Vertex with maximum betweenness centrality.

$ ./graph betweenness <filename>

4. Examples

This program only supports CSV files where rows represent edges. Each edge is formed by the vertices names and a weight.

4.1. Simple graph

To represent the following graph

alt text

the CSV file would be:

A,B,0.9
A,C,3
B,D,4
C,D,2.6
D,E,1

This example is already on this repository (see simple.csv).

To find the shortest path between A and E, execute

$ ./graph path simple.csv A E

and the program should return

Shortest path between 'A' and 'E'

Distance: 5.9
    Path: E <- D <- B <- A

4.2. European cities

This repository also includes an example of European cities and the driving distances in hours between them. See europe.csv.

alt text

To find longest path among the all possible shortest paths, execute:

$ ./graph diameter europe.csv

And the result would be from Lisbon to Sofia!

Graph diameter: longest path among the shortest paths between all vertices

Distance: 52
    Path: sofia <- bucharest <- budapest <- bratislava <- prague <- berlin <- paris <- madrid <- lisbon

lingprog-graph's People

Contributors

mariosimao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.