Package: io¶
In this package are collected the modules that are used to read and write multilevel graphs from and to files.
Module: GEXF¶
- write_gexf(ml_graph, file_path, description=None)[source]¶
Write a GEXF file for the given MultilevelGraph in the specified file path. The produced GEXF file will contain just the core information, in order to retain the graph structure and information including nodes and edges attributes.
For visualization purposes, use
write_gexf_for_viz()instead.- Parameters:
ml_graph (MultilevelGraph) – the MultilevelGraph to write
file_path (str) – the path of the file to write
description (str | None) – a description of the graph to add in the metadata of the GEXF file
- write_gexf_for_viz(ml_graph, file_path, description=None, node_label_func=<function _default_node_label_func>, node_color_func=<function _default_node_color_func>, node_size_func=<function _default_node_size_func>, edge_color_func=<function _default_edge_color_func>, edge_thickness_func=<function _default_edge_thickness_func>)[source]¶
Write a GEXF file for the given MultilevelGraph in the specified file path. The produced GEXF file will contain all the information for visualization such as visual attributes and extra edges between children and supernodes.
More specifically, all the extra edges between children and supernodes will have their color set to the child color and will be made semi-transparent in the visualization to distinguish them from the edges between supernodes of the same level. Furthermore, an extra boolean edge attribute same_level will be added to distinguish between original and added edges, having the value 1 (true) and 0 (false) respectively.
The visualization attributes can be customized by passing the appropriate functions as parameters.
- Parameters:
ml_graph (MultilevelGraph) – the MultilevelGraph to write
file_path (str) – the path of the file to write
description (str | None) – a description of the graph to add in the metadata of the GEXF file
node_label_func (Callable[[Supernode], str]) – a function that takes a Supernode and returns the label for the node. The default function returns the key of the supernode if a ‘label’ custom attribute is not present.
node_color_func (Callable[[Supernode], Tuple[str, str, str, str]]) – a function that takes a Supernode and returns the color for the node. The default function returns a color based on the hash of the supernode key if a ‘color’ custom attribute is not present.
node_size_func (Callable[[Supernode], str]) – a function that takes a Supernode and returns the size for the node. The default function returns the size of the supernode multiplied by 10 if a ‘size’ custom attribute is not present.
edge_color_func (Callable[[Superedge], Tuple[str, str, str, str]]) – a function that takes a Superedge and returns the color for the edge. The default function returns a color based on the hash of the supernode key if a ‘color’ custom attribute is not present.
edge_thickness_func (Callable[[Superedge], str]) – a function that takes a Superedge and returns the thickness for the edge. The default function returns the size of the edge if a ‘thickness’ custom attribute is not present.