riedev_graph 0.1.0 copy "riedev_graph: ^0.1.0" to clipboard
riedev_graph: ^0.1.0 copied to clipboard

outdated

A graph library with basic algorithms and export functionality.

A graph library #

This repository includes a graph data structure and some basic graph algorithms like depth and breath search.


//      1
//    /   \ 
//   2     3
//  / \   / \
// 4   5 6   7

var g = Graph<int, Edge<int>>(false/*No double edges between two nodes.*/);

g.addEdges([Edge(1, 2), 
            Edge(1, 3), 
            Edge(2, 4), 
            Edge(2, 5), 
            Edge(3, 6), 
            Edge(3, 7)]);

To export the graph you can use the class DotFile with a fluent interface. See the example below.

var dotFile = DotFile<int, Edge<int>>();
  
dotFile.addGraph(g, graphName: "BinaryGraph")
  .setFileName("binaryGraph.dot")
  .setNodeStyle(node: 1)
    .setColor("#328fa8")
    .setFillColor("#eb8934")
    .setShape(NodeShape.diamond)
    .setLabel((n, idx) => "Node: $idx")
    .apply()
  .setEdgeStyle()
    .setColor("#328fa8")
    .setShape(EdgeShape.dashed)
    .setLabel((e, sourceIdx, targetIdx) => "Edge: $sourceIdx -> $targetIdx")
    .apply()
  .export();

These example will create a binaryGraph.dot file. You can convert this file to a svg. Install Graphviz with brew install graphviz and use the command dot -Tsvg binaryGraph.dot -o outfile.svg





Enjoy it 😃

1
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A graph library with basic algorithms and export functionality.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

MIT (LICENSE)

More

Packages that depend on riedev_graph