ChainGraph.addEdge
- ChainGraph.addEdge(first, second)
Insert a new edge into the graph.
- Parameters:
first (
int) – the id of one node of the new inserted edgesecond (
int) – the id of the other node of the new inserted edge
- Raises:
pyagrum.InvalidNode – If first or second does not belong to the graph nodes.
pyagrum.InvalidEdge – If an arc already connects first and second.
pyagrum.InvalidPartiallyDirectedCycle – If the edge would create a partially directed cycle.
- Return type:
None
Example
import pyagrum as gum
cg = gum.fastChainGraph("A->B;C")
cg.addEdge(1, 2)
cg.edges()
# {(1, 2)}
try:
cg.addEdge(0, 2) # A->B-C-A would be a partially directed cycle
except gum.InvalidPartiallyDirectedCycle:
print("refused")
Class