Module: graphs (graph creation and manipulation)
Graph support
Basic Graph object support and manipulation
Classes
Graph
-
class Graph[source]
Graph base class
- Variables
-
-
addEdge(v1, v2)[source]
Adds an edge
:param int v1: vertex 1 index
:param int v2: vertex 2 index
:raises GraphError: if edge is loop
-
addVertex(vname)[source]
Adds a vertex (by name)
- Parameters
vname – vertex name
- Returns
vertex index
- Return type
int
- Raises
DuplicateName – if vname already exists
-
abstract dotFormat(size)[source]
Some dot representation
- Parameters
-
Returns:
str:
-
vertexIndex(vname, autoCreate=False)[source]
Return vertex index
- Parameters
-
- Return type
int
- Raises
GraphError – if vname not found
DiGraph
-
class DiGraph[source]
Directed graph base class
-
addEdge(v1, v2)[source]
Adds an edge
- Parameters
-
-
static dotDrawEdge(st1, st2, sep='\n')[source]
Draw a transition in Dot Format
- Parameters
-
- Return type
str
-
dotDrawVertex(sti, sep='\n')[source]
Draw a Vertex in Dot Format
- Parameters
-
- Return type
str
-
dotFormat(size='20,20', direction='LR', sep='\n', strict=False, maxLblSz=10)[source]
A dot representation
- Parameters
direction (str) – direction of drawing
size (str) – size of image
sep (str) – line separator
maxLblSz – max size of labels before getting removed
strict – use limitations of label sizes
- Returns
the dot representation
- Return type
str
Changed in version 0.9.8.
-
inverse()[source]
Inverse of a digraph
DiGraphVm
-
class DiGraphVm[source]
Directed graph with marked vertices
- Variables
MarkedV (set) – set of marked vertices
-
markVertex(v)[source]
Mark vertex v
- Parameters
v (int) – vertex