graph

unidirected graph implementation using adjacency list
Index Commits Files Refs README LICENSE

Graph implementation in C

example-output

Simple graph data structure implementation in C using adjacency list. Featuring graph output to stdout formatted in dot language.

Compiling and running

$ make -j $(nproc)
$ ./main

Example output

This is the output when using the graph_print function:

strict graph G {
    1 -- {2, 5}
    2 -- {1, 3, 5}
    3 -- {2, 4}
    4 -- {3, 5, 6}
    5 -- {1, 2, 4}
    6 -- {4}
}

the output is formatted in dot language so it can be processed later by other tools. Another function exists graph_print_format which does the same as graph_print but adds graphviz attributes so it produces a nicer representation of the graph when parsed with dot.

Generating a preview of the graph

First make sure you have graphviz package installed, then just pipe the output of the program to dot:

$ ./main | dot -T png -o out.png

this will generate a png file containing a nice representation of the graph. You can open it with you preferred image viewer.

License

MIT