Directed Graph

a directed graph
class pyagrum.DiGraph(*args)

DiGraph represents a Directed Graph.

DiGraph() -> DiGraph

default constructor

DiGraph(src) -> DiGraph
Parameters:

Methods

addArc()

Add an arc from tail to head.

addNode()

addNodeWithId()

Add a node by choosing a new NodeId.

addNodes()

Add a set of n nodes.

adjacencyMatrix()

adjacency matrix from a graph/graphical models

ancestors()

give the set of nodeid of ancestors of a node

arcs()

Returns the set of arcs in the graph.

children()

clear()

Remove all the nodes and arcs from the graph.

completeGraph()

Create a complete directed graph with n nodes.

connectedComponents()

Returns the weakly connected components of the graph.

connectedComponentsCount()

number of connected components

connectedComponentsList()

connected components as a dict of sets

descendants()

give the set of nodeid of descendants of a node

directedPath()

Return a shortest directed path from node1 to node2, or None if no such path exists.

directedUnorientedPath()

Return a shortest path from node1 to node2 ignoring arc orientation, or None if no path exists.

empty()

Check if the graph is empty.

emptyArcs()

Check if the graph doesn’t contains arcs.

eraseArc()

Erase the arc between n1 and n2.

eraseChildren()

Erase the arcs heading through the node’s children.

eraseNode()

Erase the node and all the related arcs.

eraseParents()

Erase the arcs coming to the node.

existsArc()

Check if an arc exists between n1 and n2.

existsNode()

Check if a node with a certain id exists in the graph.

family()

Return the family of a node: the node itself plus all its parents.

hasDirectedPath()

Check if a directedpath exists between from and to.

hasName()

Check whether a node has an explicitly assigned name.

idFromName()

Return the id of the node with the given name, or None if no such name exists.

idsFromNames()

The ids of nodes given by their names, in a container of the same type.

nameFromId()

Return the name of a node, or its id as a string if no name was set.

namesFromIds()

The names of nodes given by their ids, in a container of the same type.

nodes()

parents()

saveGUM()

Save the graph as a .jgum (text) or .bgum (binary) file (its class, its nodes with their names, its arcs, edges and marks).

saveGUMstring()

Save the graph as a jgum string (see pyagrum.graphFromGUMString to read it back).

setName()

Assign a name to a node.

size()

sizeArcs()

toDot()

topologicalOrder()