graph

unidirected graph implementation using adjacency list
Index Commits Files Refs README LICENSE
ModeNameSize
-rw-r--r--LICENSE21L
-rw-r--r--Makefile21L
-rw-r--r--README.md50L
-rw-r--r--main.c283L
-rw-r--r--queue.c64L
-rw-r--r--queue.h29L
-rw-r--r--stack.c44L
-rw-r--r--stack.h25L

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