Remap Node Identifier

The Remap Node Identifier operation can be utilized to remap the id field of nodes in a graph.

The main entry point is the kgx.graph_operations.remap_node_identifier method that takes an instance of kgx.graph.base_graph.BaseGraph along with a category, alternative_property, and prefix as arguments.

kgx.graph_operations.remap_node_identifier

kgx.graph_operations.remap_node_identifier(graph: kgx.graph.base_graph.BaseGraph, category: str, alternative_property: str, prefix=None) → kgx.graph.base_graph.BaseGraph[source]

Remap a node’s ‘id’ attribute with value from a node’s alternative_property attribute.

Parameters
  • graph (kgx.graph.base_graph.BaseGraph) – The graph

  • category (string) – category referring to nodes whose ‘id’ needs to be remapped

  • alternative_property (string) – property name from which the new value is pulled from

  • prefix (string) – signifies that the value for alternative_property is a list and the prefix indicates which value to pick from the list

Returns

The modified graph

Return type

kgx.graph.base_graph.BaseGraph