Graph Conversion functions
The conversion functions are a collection of different handy helper functions for converting your input graphs between different toolboxes.
Popular supported formats are:
- numpy arrays
- networkx graphs
- dgl graphs
- scipy sparse matrices
PHOTONAI Graph will handle necessary conversions in your pipeline automatically.
Graph Conversion Functions
check_dgl(graphs, adjacency_axis=None, feature_axis=None)
Checks the input and converts it to dgl format
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graphs |
graphs to be converted |
required | |
adjacency_axis |
position of the adjacency matrix |
None
|
|
feature_axis |
position of the feature matrix |
None
|
dense_to_dgl(graphs, adjacency_axis=None, feature_axis=None)
Converts dense matrices to dgl graphs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graphs |
graphs represented in dense format |
required | |
adjacency_axis |
position of the adjacency matrix |
None
|
|
feature_axis |
position of the feature matrix |
None
|
dense_to_igraph(graphs, adjacency_axis=None, feature_axis=None)
Converts dense matrices to igraph Graph objects :param graphs: np.ndarray or np.matrix graphs represented as dense format :param adjacency_axis: int, default=None position of the adjacency axis :param feature_axis: int, default=None position of the feature axis :return: igraph_graphs: Converted list of Igraph objects
dgl_to_dense(graphs, in_fmt='csr')
turns dgl graphs into dense matrices
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graphs |
list of dgl graphs |
required | |
in_fmt |
format of the scipy sparse matrix used in the intermediary step |
'csr'
|
dgl_to_sparse(graphs, fmt='csr')
turns dgl graphs into sparse matricesParameters
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graphs |
list of dgl graphs |
required | |
fmt |
format of the scipy sparse matrix used in the intermediary step |
'csr'
|
sparse_to_dense(graphs, features=None)
convert sparse matrices to numpy array
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graphs |
a list of scipy sparse matrices or a single sparse matrix |
required | |
features |
if a feature matrix or a list of those is specified they are incorporated into the numpy array |
None
|