DiGraph.idsFromNames

DiGraph.idsFromNames(names)

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

Parameters:

names (str or list or tuple or set or frozenset or dict) – a node name, or a container of node names: a list, a tuple, a set, a frozenset or a dict (keys and values), possibly nested (e.g. a set of pairs of names)

Returns:

names where every name is replaced by the id of its node

Return type:

int or list or tuple or set or frozenset or dict

Raises:
  • TypeError – if an element is not a str, or a container is not a list, a tuple, a set, a frozenset nor a dict

  • pyagrum.NotFound – if a name is not the name of a node (a node without name can not be found by its id written as a string)

See also

namesFromIds

the converse conversion

Example

import pyagrum as gum

g = gum.fastDiGraph("A->B->C->A")
g.idsFromNames([("C", "A"), ("A", "B")])
# [(2, 0), (0, 1)]

Used by

DiGraph, DAG

Inheritance diagram of pyagrum.DiGraph, pyagrum.DAG

Overridden in

UndiGraph.idsFromNames