module graph.graphviz_helper#

Short summary#

module mlstatpy.graph.graphviz_helper

graphviz helper

source on GitHub

Functions#

function

truncated documentation

draw_graph_graphviz

Draws a graph using Graphviz.

edges2gv

Converts a graph into a GraphViz file format.

run_graphviz

Run GraphViz.

Documentation#

graphviz helper

source on GitHub

mlstatpy.graph.graphviz_helper.draw_graph_graphviz(vertices, edges, image=None, engine='dot')#

Draws a graph using Graphviz.

Paramètres:
  • edges – see below

  • vertices – see below

  • image – output image, None, just returns the output

  • enginedot or neato

Renvoie:

Graphviz output or the dot text if image is None

The function creates a file <image>.gv if image is not None.

edges    = [ (1,2, label, color), (3,4), (1,3), ... ]  , liste d'arcs
vertices = [ (1, label, color), (2), ... ]  , liste de noeuds
image = nom d'image (format png)

source on GitHub

mlstatpy.graph.graphviz_helper.edges2gv(vertices, edges)#

Converts a graph into a GraphViz file format.

Paramètres:
  • edges – see below

  • vertices – see below

Renvoie:

gv format

The function creates a file <image>.gv.

<<<

from mlstatpy.graph.graphviz_helper import edges2gv
gv = edges2gv([(1, "eee", "red")],
              [(1, 2, "blue"), (3, 4), (1, 3)])
print(gv)

>>>

    digraph{
    "1" [label="eee",fillcolor=red,color=red];
    2 ;
    3 ;
    4 ;
    "1" -> "2" [label="blue"];
    "3" -> "4";
    "1" -> "3";
    }

source on GitHub

mlstatpy.graph.graphviz_helper.run_graphviz(filename, image, engine='dot')#

Run GraphViz.

Paramètres:
  • filename – filename which contains the graph definition

  • image – output image

  • enginedot or neato

Renvoie:

output of graphviz

source on GitHub