Skip to content

razmikTovmas/Graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graph

Workflow Badge

A Graph data structure

This library provides a minimal implementation of a directed/weighted graph data structure. Internally, an adjacency list is used to represent nodes and edges.

Description: Wiki

A graph is a structure amounting to a set of objects in which some pairs of the objects are in some sense "related". There are two main parts of a graph:

  • The nodes (vertices) where the data is stored i.e. the numbers in the image
  • The edges (connections) which connect the nodes i.e. the lines between the numbers in the image

Graph

Graphs can be directed or undirected

  • Directed graph: The relationships are based on the direction of the edges. It can be a one way relationship or a two-way relationship, but it must be explicitly stated.
  • Undirected graph: The relationship exists in both directions. Can be represented via directed graph.

Traversing a graph

  • Breadth first search: Wiki
  • Depth first search: Wiki

Algorithms

  • Mother Node in a Graph: Info
  • Number of paths between nodes: Info
  • Is cyclic: Info
  • Has negative cycle: Info

Serialization

graph.serialize("fileName");
graph.deserialize("fileName");

Serializes the graph to the file, deserialize from the file The following will be in the file

5 
A 2
1 5 2 2
B 1
3 1
C 1
4 4
D 1
4 3
E 1
0 1

How to Build

mkdir ./build
cd ./build
cmake ..
make -j <job count>

Code Examples

Running Examples

cd build/examples
./<example_name>

License

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

About

A library to provide a minimal implementation of a directed/weighted graph data structure.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors