Nodes

Class Description

class paminco.net.Nodes(data, dtype_float=None, dtype_int=None, map_labels=True, copy: bool = False)[source]

Class that contains the nodes/vertices of a network.

A Nodes object can be instantiated in several ways:
Nodes(n)

where n is a Nodes object.

Nodes(nodes)

where nodes is array_like and contains either node labels or node indices. If no indices are given, they are set automatically.

Nodes(nodes, zone)

where nodes and zone are array_like of shape (n, ). zone must be boolean array denoting if a node is a zone, mostly used for traffic networks.

Nodes(nodes, xy, zone)

where nodes and zone are array_like of shape (n, ) and xy is array_like of shape (n, 2) and contains the coordinates of the nodes.

Nodes(node_labels, node_indices, xy, zone)

where node_labels and node_indices and zone are are array_like of shape (n, ) and xy is array_like of shape (n, 2).

Parameters
datanode_data

Input data.

dtype_floatdtype, default=numpy.float_

Datatype for X and Y coordinates.

dtype_intdtype, default=int

Datatype for node indices.

map_labels: None, bool, dict, or callable, default=True

Determines mapping of labels to indices if no indices are given or vice versa. If None or False, indices / labels are set to -9999 / ‘invalid’. If dict, mapping by this dict. If True, indices are set to 0, 1, …, n-1, labels to indices as str. If callable, use callable with signature indices = callable(labels) or labels = callable(indices).

copybool, default=False

Whether to create a copy of the inputs in data.

Attributes
index
node
zone
has_zones

bool: Whether Nodes object has any zone.

x

ndarray (m, ) of floats: X coordinates.

y

ndarray (m, ) of floats: Y coordinates.

Methods

Nodes.from_edges(edges, **kw)

Nodes.from_xml(data[, return_data])

Load object from .xml data.

Nodes.from_npz(data[, prefix])

Construct object from .npz file.

Nodes.set_mappings()

(Re)-set labels <-> indices mappings.

Nodes.get_pos()

Nodes.delete_nodes(nodes[, return_indices])

Delete nodes from Nodes object.

Nodes.to_df(**kwargs)

Get object as pandas DataFrame.

Nodes.add_to_etree(root[, overwrite])

Add node data to xml.etree.ElementTree.Element.

Nodes.make_save_dict([prefix, save_dict])

Generate dict to save object with numpy.savez.

Nodes.save_to_numpy(file, **kwargs)

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