Zum Inhalt

graphimporter

dsstools.graphimporter

logger = get_logger('WDCAPI') module-attribute

GraphImporter(identifier=None, *, token=None, api='https://dss-wdc.wiso.uni-hamburg.de/api', insecure=False, timeout=60, params=None)

Bases: WDC

Class enabling graph imports from the WDC server.

Parameters:

Name Type Description Default
identifier int | None

Identifier of the network data. This is a numeric ID identifying the graph. Unintuitively, this differs from the corresponding text search data, if you need both data types.

None
token str | None

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 dict | None

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

api = api[:-1] if api.endswith('/') else api instance-attribute

endpoint = 'domaingraph' class-attribute instance-attribute

identifier = identifier instance-attribute

params = params if params else {} instance-attribute

session = requests.Session() instance-attribute

timeout = timeout instance-attribute

token property writable

Get the password token.

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.

list_wdcapi_graphs(token, timeout=60)

List accessible graph identifiers for the given token.

Comfort wrapper around the GraphImporter().list_available_graphs() object which should mirror the common structure of NetworkX.

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:

read_wdcapi(identifier, token, timeout=60, graph_type=nx.DiGraph)

Import a graph from the WDC API.

Use the identifier you select in read_wdcapi().

Comfort wrapper around the GraphImporter().get_graph() object which should mirror the common structure of NetworkX.

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.