graphimporter
dsstools.graphimporter
GraphImporter
Bases: WDCGeneric
Class enabling graph imports from the WDC server.
token
property
writable
Get the password token.
__init__(identifier=None, *, token=None, api='https://dss-wdc.wiso.uni-hamburg.de/api', insecure=False, timeout=60, params=None)
Base class for interacting with the WDC API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
Optional[str]
|
Identifier of the network data. |
None
|
token
|
Optional[str]
|
Token for authorization. |
None
|
api
|
str
|
API address to send request to. Leave this as is. |
'https://dss-wdc.wiso.uni-hamburg.de/api'
|
insecure
|
bool
|
Hide warning regarding missing https. |
False
|
timeout
|
int
|
Set the timeout to the server. Increase this if you request large networks. |
60
|
params
|
Optional[dict]
|
These are additional keyword arguments passed onto the API endpoint. See https://dss-wdc.wiso.uni-hamburg.de/#_complex_datatypes_for_the_api_requests for further assistance. |
None
|
get_edges()
Get the edges of the selected graph.
Args:
Returns:
| Type | Description |
|---|---|
|
List of edges, containing a 3-tuple of the structure (from, |
|
|
to, weight). |
get_graph(graph_type=nx.DiGraph)
Get the full graph containing nodes and edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph_type
|
Type of graph to create. (Default value = nx.DiGraph) |
DiGraph
|
Returns:
| Type | Description |
|---|---|
|
Graph from API |
get_nodes()
Get the nodes of the selected graph.
Args:
Returns:
| Type | Description |
|---|---|
|
List of nodes, containing a 2-tuple of the structure (ID, |
|
|
{additional_data_dict}). |
list_available_graphs()
List available graphs for the current token.
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of dicts containing the graphs with metadata. |
read_wdcapi(identifier, token, timeout=60, graph_type=nx.DiGraph)
Import a graph from the WDC API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
str: Identifier of the graph. |
required |
token
|
str
|
str: Token to authenticate with. |
required |
timeout
|
int
|
int: Timeout in seconds after the request cancels. For very large graphs this should be increased. (Default value = 60) |
60
|
graph_type
|
Type of graph to return. For crawled graphs nx.DiGraph is recommended. (Default value = nx.DiGraph) |
DiGraph
|
Returns:
| Type | Description |
|---|---|
|
The imported graph. |
read_wdcapi_graphs(token, timeout=60)
List accessible graph identifiers for the given token.
Use the identifier in read_wdcapi().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
str: Token to authenticate with. |
required |
timeout
|
int
|
int: Timeout in seconds after the request cancels. Leave at default. (Default value = 60) |
60
|
Returns: