Mixed Graph

a mixed graph
class pyagrum.MixedGraph(*args)

MixedGraph represents a graph with both arcs and edges.

MixedGraph() -> MixedGraph

default constructor

MixedGraph(src) -> MixedGraph
Parameters:

Methods

addArc()

Add an arc from n1 to n2.

addEdge()

Insert a new edge into the graph.

addNode()

addNodeWithId()

Add a node by choosing a new NodeId.

addNodes()

Add n nodes.

ancestors()

give the set of nodeid of ancestors of a node

arcs()

Returns the set of arcs in the graph.

boundary()

Boundary are neighbours (not oriented), children and parents

chainComponent()

Return the chain component containing a given node.

chainComponents()

Return the chain components of the graph.

children()

clear()

Remove all the nodes and edges from the graph.

connectedComponents()

Returns the weakly connected components of the mixed graph (following both arcs and undirected edges in both directions).

descendants()

give the set of nodeid of descendants of a node

edges()

empty()

Check if the graph is empty.

emptyArcs()

Check if the graph doesn’t contains arcs.

emptyEdges()

Check if the graph doesn’t contains edges.

eraseArc()

Erase the arc between n1 and n2.

eraseChildren()

Erase the arcs heading through the node’s children.

eraseEdge()

Erase the edge between n1 and n2.

eraseNeighbours()

Erase all the edges adjacent to a given node.

eraseNode()

Erase the node and all the related arcs and edges.

eraseParents()

Erase the arcs coming to the node.

existsArc()

Check if an arc exists between n1 and n2.

existsEdge()

Check if an edge exists between n1 and n2.

existsNode()

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

hasMixedOrientedPath()

Check if there is an oriented path from node1 to node2 in the mixed graph (following arc directions).

mixedOrientedPath()

mixedUnorientedPath()

neighbours()

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).

size()

sizeArcs()

sizeEdges()

toDot()

Methods inherited from UndiGraph

adjacencyMatrix()

adjacency matrix from a graph/graphical models

completeGraph()

Create a complete undirected graph with n nodes.

connectedComponentsCount()

number of connected components

connectedComponentsList()

connected components as a dict of sets

hasName()

Check whether a node has an explicitly assigned name.

hasUndirectedCycle()

Checks whether the graph contains cycles.

hasUndirectedPath()

Check whether two nodes are connected by an undirected path.

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()

partialUndiGraph()

setName()

Assign a name to a node.

undirectedPath()

Return a shortest undirected path between two nodes, or None if no path exists.

Methods inherited from DiGraph

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.

family()

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

hasDirectedPath()

Check if a directedpath exists between from and to.

topologicalOrder()