Skip to content

mgsalerno/queue-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graph library

Graph library using queues in C.

Status: Finished

About | Installation | Usage | Technologies | License

About

This library is a simple way to use graphs data structures in C. It uses queues (basically lists) to store the graph, aswell as the vertices and edges and provides functions for creating and destroying graphs, adding and removing vertices, adding and removing edges and more. It's not the best approach to the implementation of graphs, but for small projects it works just fine. If you want to see more, you can check the header files (graph.h and queue.h).

What it supports What it doesn't support
undirected graphs weighted edges
directed graphs
unweighted vertices
weighted vertices
unweighted edges
connected graphs
disconnected graphs

Installation

Dependencies

Usually it is not necessary to install anything, but if it shows some error or it can't find some of the C libraries you can try to install the following package:

sudo apt update
sudo apt install build-essential

Usage

In the src folder, use the makefile to compile everything:

make

Run the main program to see the outputs using the example graph (in this case it's the Petersen graph):

./main -f petersen

To clean up the files generated by the makefile, just run:

make clean

To purge the files generated by the makefile, just run:

make purge

Input and Output

The input and output of this library have a specific format, which is one or two vertices by line separated with a blank space. The vertices must be represented by integer values.

Every pair of vertices in a line means that those vertices will have an edge between them, like in the example below, where the vertices 1 and 2 will have an edge between them. If the graph is directed, the direction respects the order of the vertices in the input. In this case, there will be an edge from 1 to 2 but not from 2 to 1.

You can have the vertices line by line or have line breaks between the lines, both are supported.

If you want to see a complete example of the input format, check petersen, which shows how you can enter the vertices for the Petersen Graph both with and without line breaks. In case that the input file is badly formatted, the program will warn the user.

Example input:

1 2
1 3
3 4
5

Technologies

  • C language

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Graph library using queues in C.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published