Edges

Class Description

class paminco.net.Edges(data, directed_flow: bool = True, map_labels_to_indices=True, map_indices_to_labels=True, dtype_float=None, dtype_int=None, copy: bool = False)[source]

Class that contains the edges/links of a network.

An edges object can be instantiated in several ways:
Edges(e)

where e is an Edges object. Data in e will be copied if specfied by parameter copy.

Edges(st)

where st is array_like. Parameter st is converted to ndarray and is expected to me of shape (m, 2). Can be node indices or node labels specifying an edge. If labels are given, indices are mapped by map_labels_to_indices, given indices are mapped by map_indices_to_labels. Edge bounds are determined by the parameter directed.

Edges((st, bounds))

where st is array_like and bounds is tuple (lower, upper) specifying bounds used for all edges or array_like of shape (m, 2) marking individual bounds for all edges.

Edges((labels, indices, bounds))

where labels, indices are array_like of shape (m, 2) and bounds is tuple (lower, upper) specifying bounds used for all edges or array_like of shape (m, 2) containing individual bounds for all edges.

Parameters
datandarray, or tuple of ndarray

Edge data.

directed_flowbool, default=True

Controls default values for None in bounds. If True, lower bounds are set to 0 and False to -inf. Missing upper bounds are set to inf.

map_labels_to_indicesNone, bool, dict, or callable, default=True

Determines mapping of labels to indices if no indices are given. If None or False, indices of edges will be set to -9999, denoting invalid edge indices. If dict, labels will be mapped by this dict. If True, node indices are set to 0, 1, …, n-1. If callable, use callable with signature indices = callable(labels).

map_indices_to_labelsNone, bool, dict, or callable, default=True

Determines mapping of indices to indices if no labels are given. If None or False, indices of edges will be set to ‘invalid’, denoting invalid edge labels. If dict, indices will be mapped by this dict. If True, node labels are set to node indices as str. If callable, use callable with signature labels = callable(indices).

dtype_floatdtype, default=numpy.float_

Datatype for edge bounds.

dtype_intdtype, default=int

Datatype for edge bounds.

copybool, default=False

Whether to create a copy of the inputs in data.

Attributes
flow_directionsndarray

Ndarray of shape (m, ). A -1 denotes an edge with lb < 0 and ub <= 0. A 0 denotes an edge with lb < 0 and ub > 0. A 1 denotes an edge with lb >=0 and ub > 0.

Methods

Edges.from_xml(data[, return_data])

Load object from .xml data.

Edges.from_npz(data[, prefix])

Construct object from .npz file.

Edges.to_df(**kwargs)

Get object as DataFrame.

Edges.get_flow_df(x[, labels, colname_flow])

Edges.get_directed([w, backward_positive])

Edges.get_duplicate_edges()

Edges.map_labels(d)

Map edge labels by d.

Edges.add_to_etree(root[, overwrite, ...])

Add edge data to XML Element.

Edges.make_save_dict([prefix, save_dict])

Generate dict to save object with numpy.savez.

Edges.save_to_numpy(file, **kwargs)

Save object into a single file in uncompressed .npz format.

Attributes

Edges.lb

ndarray (m, ) of floats: lower bound.

Edges.ub

ndarray (m, ) of floats: upper bound.

Edges.s

ndarray (m, ) of int: source ids.

Edges.t

ndarray (m, ) of int: target ids.

Edges.source_lbl

ndarray (m, ) of str: sources labels.

Edges.target_lbl

ndarray (m, ) of str: target labels.

Edges.dtype_int

dtype of int data.

Edges.dtype_float

dtype of float data.

Edges.flow_forward

Edges.flow_forward

Edges.flow_undirected