Skip to content

Guzik1/MathGraph_for_.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mathematical Graph for C#/.Net

This project is a simple implement a mathematical graph library that provides stores data (with data in node and data in edge) represents on graph and algorithm to operating on this data.

General info

Features:

  • simple to use
  • generic data in node and edge
  • supports weighted graph
  • supports directed graph
  • minimal spanning tree Kruskal and Prim algorithm (for weighted graph)
  • shortest Dijkstra path algorithm (for weighted graph)
  • node coloring
  • traversal
  • save graph system (save to file).
  • graph to serializable graph and conversely converter (easy to save)!

Setup

MathGraph available in Nuget package.
MathGraphSave available in Nuget package.
Compiling bin library is located in /bin folder.
Copy Graph and Priority Queue (.dll files) to your project (and GraphSave when you save graph to file).

Simple code example

Data in node and edge is int. Graph is unweighted and undirected (simple graph)

// < Type of node data, type of edge data > (isWeighted, isDirected)
Graph<int, int> graph = new Graph<int, int>();

// Add:
graph.AddNode(0);   // parameters: (data of node)
graph.AddNode(1);

graph.AddEdge(graph[0], graph[1]);  // add edge beetwen node 0 and 1
// or
graph.AddEdge(graph[0], graph[1], edgeData: 10);  // add edge beetwen node 0 and 1, and data in edge = 10

// Indexers:
Node<int, int> node0 = graph[0]; // return node from index (reference to node fields)
Edge<int, int> edge01 = graph[0, 1];  // parameters [node from, node to], return edge beetwen node 0 and 1

// Call to data:
Console.WriteLine(node0.Data);
Console.WriteLine(edge01.Data); /* or */  Console.WriteLine(graph[0, 1].Data);

// Remove:
graph.RemoveEdge(node0, graph[1]); // remove edge beetwen node 0 and 1
graph.RemoveNode(graph[0]);  /* or */  graph.RemoveNode(node0);  // node 1 becomes to node 0

For more information, you must view Graph documentation.
When you save a graph, view GraphSave documentation.
Examples available here.

Built with

Status

Version: Beta.
This project is: in progress. We add new function, may changes existing method/class names and refactorize project code.

License

MIT License © Sebastian Guzik.

About

Graph library for C# / .Net

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages