def node_type(self, graph_id, node_id):
"""Get a list of the immediate types of a node."""
if graph_id not in self.nodes():
raise HierarchyError(
"Graph '%s' is not defined in the hierarchy!"
% graph_id
)
if node_id not in self.node[graph_id].graph.nodes():
raise HierarchyError(
"Graph '%s' does not have a node with id '%s'!"
% (graph_id, node_id)
)
types = {}
for _, typing in self.out_edges(graph_id):
mapping = self.edge[graph_id][typing].mapping
if node_id in mapping.keys():
types[typing] = mapping[node_id]
return types
评论列表
文章目录