specless.io

This module contains functions to save and draw graphs and strategies.

Examples

Draw a graph: >>> import networkx as nx >>> from specless.io import draw_graph >>> G = nx.DiGraph() >>> G.add_node(“A”) >>> G.add_node(“B”) >>> G.add_edge(“A”, “B”) >>> draw_graph(G, “graph.png”) <IPython.core.display.Image object>

Draw a strategy: >>> from specless.strategy import PlanStrategy >>> from specless.io import save_strategy >>> plan = [“A”, “B”] >>> strategy = PlanStrategy(plan) >>> save_strategy(strategy, “strategy.png”)

Save a graph: >>> from specless.io import save_graph >>> save_graph(G, “graph.png”)

Save a strategy: >>> save_strategy(strategy, “strategy.png”)

Notes

This module is a work in progress.

Functions

add_labels

Add labels to the nodes and edges of a graph.

draw_graph

Draw a class that is derived from a networkx DiGraph and save it to a file.

edge_label_function

Generate a label for an edge based on its data.

node_label_function

Generate a label for a node based on its data.

save_graph

Save a class that is derived from a networkx MultiDiGraph to a file.

save_strategy

Save a strategy class to a file.