In the current Graph-class, we try to handle higher-order graphs as well, which leads to a lot of checks like order > 1. These checks conflict with the new classes like EventGraph that are strictly higher-order and need to be removed once we have dedicated higher-order classes for every graph type that we are interested in.
Note that these checks also extend to visualisations:
| def_compute_node_data(self) ->None: |
| """Build node DataFrame with visual attributes. |
| |
| Creates indexed DataFrame for all nodes, handling higher-order networks |
| by converting tuple nodes to string representation. Assigns attributes |
| from config defaults, network data, and user arguments. |
| """ |
| # initialize values |
| nodes: pd.DataFrame=pd.DataFrame(index=self.network.nodes) |
| # if higher-order network, convert node tuples to string representation |
| ifself.network.order>1: |
| nodes.index=nodes.index.map(lambdax: self.config["separator"].join(map(str, x))) |
| forattributeinself.attributes: |
| # set default value for each attribute based on the pathpyG.toml config |
| ifisinstance(self.config.get("node").get(attribute, None), list|tuple): # type: ignore[union-attr] |
| nodes[attribute] = [self.config.get("node").get(attribute, None)] *len(nodes) # type: ignore[union-attr] |
| else: |
| nodes[attribute] =self.config.get("node").get(attribute, None) # type: ignore[union-attr] |
| # check if attribute is given as node attribute |
| iff"node_{attribute}"inself.network.node_attrs(): |
| nodes[attribute] =self.network.data[f"node_{attribute}"] |
| # check if attribute is given as argument |
| ifattributeinself.node_args: |
| nodes=self._assign_argument(attribute, self.node_args[attribute], nodes) |
| |
| # save node data |
| self.data["nodes"] =nodes |
IndexMap also tries to handle higher-order graphs under the hood:
| The methods above work analogously for higher-order IDs: |
| |
| >>> print(index_map.to_id(1)) |
| ('A', 'C') |
| >>> print(index_map.to_ids([[0], [2]])) |
| [[['A' 'B']] |
| [['B' 'C']]] |
We should discuss if it might be better to also have EventIndexMap and HigherOrderIndexMap that handle these things natively.
In the current
Graph-class, we try to handle higher-order graphs as well, which leads to a lot of checks likeorder > 1. These checks conflict with the new classes likeEventGraphthat are strictly higher-order and need to be removed once we have dedicated higher-order classes for every graph type that we are interested in.Note that these checks also extend to visualisations:
pathpyG/src/pathpyG/visualisations/network_plot.py
Lines 120 to 146 in 02c0dc6
IndexMapalso tries to handle higher-order graphs under the hood:pathpyG/src/pathpyG/core/index_map.py
Lines 62 to 68 in 02c0dc6
We should discuss if it might be better to also have
EventIndexMapandHigherOrderIndexMapthat handle these things natively.