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 edge

  • second (int) – the id of the other node of the new inserted edge

Raises:
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

ChainGraph