GithubHelp home page GithubHelp logo

dctucker / nimgraphviz Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aveheuzed/nimgraphviz

1.0 1.0 0.0 57 KB

A nim library for making graphs with GraphViz and DOT (based on PyGraphviz)

Nim 100.00%

nimgraphviz's Introduction

nimgraphviz

The nimgraphviz module is a library for making graphs using GraphViz based on PyGraphviz.

To use it, add

requires "nimgraphviz >= 0.3.0"

to your .nimble file.

To export images, you must have GraphViz installed. Download it here: https://graphviz.gitlab.io/download.

Read the docs here.

Here is an example of creating a simple graph:

# create a directed graph
let graph = newGraph[Arrow]()

# You can add subgraphs to it:
let sub = newGraph(graph)
# You can nest subgraphs indefinitely :
# let subsub = newGraph(sub)

# The subgraph is automatically included in the main graph
# when you export it. It can also work standalone.
# Note that some layout engines behave differently when a subgraph
# name begins with "cluster". Please refer to the official GraphViz
# documentation for details.

# set some attributes of the graph:
graph["fontsize"] = "32"
graph["label"] = "Test Graph"
# (You can also access nodes and edges attributes this way :)
# graph["a", "bgcolor"] = "red"
# graph["a"->"b", "arrowhead"] = "diamond"

# add edges:
# (if a node does not exist already it will be created automatically)
graph.addEdge("a"->"b", ("label", "A to B"))
graph.addEdge("c"->"b", ("style", "dotted"))
graph.addEdge("b"->"a")
sub.addEdge("x"->"y")

graph.addNode("c", ("color", "blue"), ("shape", "box"),
                    ("style", "filled"), ("fontcolor", "white"))
graph.addNode("d", ("label", "node 'd'"))

# if you want to export the graph in the DOT language,
# you can do it like this:
# echo graph.exportDot()

# Export graph as PNG:
graph.exportImage("test_graph.png")

nimgraphviz's People

Contributors

aveheuzed avatar vindaar avatar quinnfreedman avatar samdmarshall avatar

Stargazers

Casey Tucker avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.