Skip to content

unidirected graph implementation using adjacency list

License

Notifications You must be signed in to change notification settings

mjkloeckner/graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

unidirected graph implementation using adjacency list

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published