processing
dsstools.processing
Copyright (C) 2024 dssTools Developers David Seseke david.seseke@uni-hamburg.de Katherine Shay katherine.shay@studium.uni-hamburg.de Professur Digitale Sozialwissenschaften Universität Hamburg
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Layouter
create_layout(graph, seed=None, **kwargs)
Create position dictionary according to set layout engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph |
DiGraph
|
Graph object |
required |
seed |
int
|
Set a default seed (default None) |
None
|
Returns: Dictionary of node and positions.
read_positions(filename)
Reads position from file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
Union[Path]
|
Path to file to be read. |
required |
Returns: Dictionary of nodes and positions.
update_positions(filename, graph, seed=None, overwrite=False, **kwargs)
Reads from file if it exists, otherwise creates new layout and writes to path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
Union[str, Path]
|
Filename to write positions to |
required |
graph |
Graph
|
Graph object |
required |
seed |
int
|
Positive integer value (default -1) |
None
|
overwrite |
bool
|
Overwrite existing file (default False) |
False
|
**kwargs |
Any arguments are passed to the internal layout engine |
{}
|
Returns: Dictionary of positions per Node.
NumpyEncoder
Bases: JSONEncoder
Special json encoder for numpy types.
calculate_betweenness_centrality(graph, **kwargs)
Updates the nodes in the graph with betweenness centrality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph |
DiGraph
|
nx.DiGraph The graph to calculate on. |
required |
**kwargs |
All arguments passed onto nx.betweenness_centrality (see https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.betweenness_centrality.html#betweenness-centrality) |
{}
|
Returns:
| Type | Description |
|---|---|
|
Graph including the closeness centrality. |
calculate_closeness_centrality(graph, **kwargs)
Updates the nodes in the graph with closeness centrality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph |
DiGraph
|
nx.DiGraph The graph to calculate on. |
required |
**kwargs |
All arguments passed onto nx.closeness_centrality (see https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.closeness_centrality.html#closeness-centrality) |
{}
|
Returns:
| Type | Description |
|---|---|
|
Graph including the betweenness centrality. |