FAdo.graphs

Graph support

Basic Graph object support and manipulation

class DiGraph[source]

Directed graph base class

Inheritance diagram of DiGraph
addEdge(v1, v2)[source]

Adds an edge

Parameters:
  • v1 (int) – vertex 1 index

  • v2 (int) – vertex 2 index

static dotDrawEdge(st1, st2, sep='\n')[source]

Draw a transition in Dot Format

Parameters:
  • st1 (str) – starting state

  • st2 (str) – ending state

  • sep (str) – separator

Return type:

str

dotDrawVertex(sti, sep='\n')[source]

Draw a Vertex in Dot Format

Parameters:
  • sti (int) – index of the state

  • sep (str) – separator

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

New in version 0.9.6.

Changed in version 0.9.8.

inverse()[source]

Inverse of a digraph

class DiGraphVm[source]

Directed graph with marked vertices

Variables:

MarkedV (set) – set of marked vertices

Inheritance diagram of DiGraphVm
markVertex(v)[source]

Mark vertex v

Parameters:

v (int) – vertex

class Graph[source]

Graph base class

Variables:
  • Vertices (list) – Vertices’ names

  • Edges (set) – set of pairs (always sorted)

Inheritance diagram of Graph
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:
  • size (str) – size parameter for dotviz

  • filename (str) – filename

  • direction (str) –

  • strict (bool) –

  • maxlblsz (int) –

  • sep (str) –

Returns: str:

vertexIndex(vname, autoCreate=False)[source]

Return vertex index

Parameters:
  • autoCreate (bool) – auto creation of non existing states

  • vname – vertex name

Return type:

int

Raises:

GraphError – if vname not found