5.1.3.1.4. cobramod.visualization.mapping
¶
Mapping of graph
This modules handles the mapping of a directed graph into a matrix that can be
used in Escher. The main function is
cobramod.visualization.mapping.get_mapping()
, which checks if the graph
is lineal and creates the representation in a matrix. In case of cyclic path,
it will cut it.
5.1.3.1.4.1. Module Contents¶
5.1.3.1.4.1.1. Functions¶
|
Return a set with the all the values for a given list of keys. Elements of |
|
Returns the relation parent: children as a dictionary. A key represent the |
|
Return index of item in a path, whose value is found. |
|
Returns an unformatted matrix from a graph. The matrix represent the |
|
Fills each row of the matrix with 0 until it reaches given length |
|
Formats given matrix and returns, if possible, a reduced matrix. Matrix |
|
Returns a matrix for the representation of given graph. |
|
Returns a transpose matrix for given matrix. |
- cobramod.visualization.mapping.get_all_values(dictionary: dict, keys: list) set ¶
Return a set with the all the values for a given list of keys. Elements of tuples will be added separately.
- cobramod.visualization.mapping.child_map(mapping: list, dictionary: dict) dict ¶
Returns the relation parent: children as a dictionary. A key represent the parent and the key their corresponding children
- cobramod.visualization.mapping.get_index(dictionary: dict, path: list, value) int ¶
Return index of item in a path, whose value is found.
- cobramod.visualization.mapping.unformatted_matrix(graph: dict) List[list] ¶
Returns an unformatted matrix from a graph. The matrix represent the locations of the nodes and their relationships. Graph will be cut if cyclic. Unrelated nodes will be appended separately at the end. The matrix have 0 in empty positions.
- Parameters
graph (dict) – Dictionary with relationship between nodes. A node can have multiple edges, which should be presented as values.
- Returns
List[list]: Representation of matrix
- Raises
KeyError – If keys in graph are missing
- cobramod.visualization.mapping.fill_matrix(matrix: List[list], length: int)¶
Fills each row of the matrix with 0 until it reaches given length
- cobramod.visualization.mapping.format_matrix(matrix: List[list], max_length: int) List[list] ¶
Formats given matrix and returns, if possible, a reduced matrix. Matrix will be filled with 0’s if needed.
- cobramod.visualization.mapping.get_mapping(graph: dict) List[list] ¶
Returns a matrix for the representation of given graph.
- Parameters
graph (dict) – Dictionary with relationship between nodes. A node can have multiple edges, which should be presented as values.
- Returns
List[list]: Representation of matrix
- Raises
KeyError – If keys in graph are missing