holoviews.element.graphs module#

class holoviews.element.graphs.Chord(data=None, kdims=None, vdims=None, **kwargs)[source]#

Bases: Graph

Chord is a special type of Graph which computes the locations of each node on a circle and the chords connecting them. The amount of radial angle devoted to each node and the number of chords are scaled by a weight supplied as a value dimension.

If the values are integers then the number of chords is directly scaled by the value, if the values are floats then the number of chords are apportioned such that the lowest value edge is given one chord and all other nodes are given nodes proportional to their weight.

Parameter Definitions


Parameters inherited from:

group = String(constant=True, default='Chord', label='Group')

A string describing the data wrapped by the object.

property edgepaths#

Returns the fixed EdgePaths or computes direct connections between supplied nodes.

property nodes#

Computes the node positions the first time they are requested if no explicit node information was supplied.

class holoviews.element.graphs.EdgePaths(data=None, kdims=None, vdims=None, **kwargs)[source]#

Bases: Path

EdgePaths is a simple Element representing the paths of edges connecting nodes in a graph.

Parameter Definitions


Parameters inherited from:

group = String(constant=True, default='EdgePaths', label='Group')

A string describing the data wrapped by the object.

class holoviews.element.graphs.Graph(data=None, kdims=None, vdims=None, **kwargs)[source]#

Bases: Dataset, Element2D

Graph is high-level Element representing both nodes and edges. A Graph may be defined in an abstract form representing just the abstract edges between nodes and optionally may be made concrete by supplying a Nodes Element defining the concrete positions of each node. If the node positions are supplied the EdgePaths (defining the concrete edges) can be inferred automatically or supplied explicitly.

The constructor accepts regular columnar data defining the edges or a tuple of the abstract edges and nodes, or a tuple of the abstract edges, nodes, and edgepaths.

Parameter Definitions


Parameters inherited from:

group = String(constant=True, default='Graph', label='Group')

A string describing the data wrapped by the object.

kdims = List(bounds=(2, 2), default=[Dimension('start'), Dimension('end')], label='Kdims')

The key dimensions defined as list of dimensions that may be used in indexing (and potential slicing) semantics. The order of the dimensions listed here determines the semantics of each component of a multi-dimensional indexing operation. Aliased with key_dimensions.

clone(data=None, shared_data=True, new_type=None, link=True, *args, **overrides)[source]#

Clones the object, overriding data and parameters.

Parameters#

data

New data replacing the existing data

shared_databool, optional

Whether to use existing data

new_typeoptional

Type to cast object to

linkbool, optional

Whether clone should be linked Determines whether Streams and Links attached to original object will be inherited.

*args

Additional arguments to pass to constructor

**overrides

New keyword arguments to pass to constructor

Returns#

Cloned object

dimensions(selection='all', label=False)[source]#

Lists the available dimensions on the object

Provides convenient access to Dimensions on nested Dimensioned objects. Dimensions can be selected by their type, i.e. ‘key’ or ‘value’ dimensions. By default ‘all’ dimensions are returned.

Parameters#

selectionType of dimensions to return

The type of dimension, i.e. one of ‘key’, ‘value’, ‘constant’ or ‘all’.

labelWhether to return the name, label or Dimension

Whether to return the Dimension objects (False), the Dimension names (True/’name’) or labels (‘label’).

Returns#

List of Dimension objects or their names or labels

edge_type[source]#

alias of EdgePaths

property edgepaths#

Returns the fixed EdgePaths or computes direct connections between supplied nodes.

classmethod from_networkx(G, positions, nodes=None, **kwargs)[source]#

Generate a HoloViews Graph from a networkx.Graph object and networkx layout function or dictionary of node positions. Any keyword arguments will be passed to the layout function. By default it will extract all node and edge attributes from the networkx.Graph but explicit node information may also be supplied. Any non-scalar attributes, such as lists or dictionaries will be ignored.

Parameters#

Gnetworkx.Graph

Graph to convert to Graph element

positionsdict or callable

Node positions Node positions defined as a dictionary mapping from node id to (x, y) tuple or networkx layout function which computes a positions dictionary

kwargsdict

Keyword arguments for layout function

Returns#

Graph element

node_type[source]#

alias of Nodes

property nodes#

Computes the node positions the first time they are requested if no explicit node information was supplied.

range(dimension, data_range=True, dimension_range=True)[source]#

Return the lower and upper bounds of values along dimension.

Parameters#

dim

The dimension to compute the range on.

data_rangebool

Compute range from data values

dimension_rangebool

Include Dimension ranges Whether to include Dimension range and soft_range in range calculation

Returns#

Tuple containing the lower and upper bound

select(selection_expr=None, selection_specs=None, selection_mode='edges', **selection)[source]#

Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.

Selecting by a node dimensions selects all edges and nodes that are connected to the selected nodes. To select only edges between the selected nodes set the selection_mode to ‘nodes’.

class holoviews.element.graphs.Nodes(data=None, kdims=None, vdims=None, **kwargs)[source]#

Bases: Points

Nodes is a simple Element representing Graph nodes as a set of Points. Unlike regular Points, Nodes must define a third key dimension corresponding to the node index.

Parameter Definitions


Parameters inherited from:

group = String(constant=True, default='Nodes', label='Group')

A string describing the data wrapped by the object.

kdims = List(bounds=(3, 3), default=[Dimension('x'), Dimension('y'), Dimension('index')], label='Kdims')

The key dimensions of a geometry represent the x- and y- coordinates in a 2D space.

class holoviews.element.graphs.RedimGraph(obj, mode=None)[source]#

Bases: Redim

Extension for the redim utility that allows re-dimensioning Graph objects including their nodes and edgepaths.

class holoviews.element.graphs.TriMesh(data=None, kdims=None, vdims=None, **kwargs)[source]#

Bases: Graph

A TriMesh represents a mesh of triangles represented as the simplices and nodes. The simplices represent a indices into the nodes array. The mesh therefore follows a datastructure very similar to a graph, with the abstract connectivity between nodes stored on the TriMesh element itself, the node positions stored on a Nodes element and the concrete paths making up each triangle generated when required by accessing the edgepaths.

Unlike a Graph each simplex is represented as the node indices of the three corners of each triangle.

Parameter Definitions


Parameters inherited from:

group = String(constant=True, default='TriMesh', label='Group')

A string describing the data wrapped by the object.

kdims = List(bounds=(3, 3), default=['node1', 'node2', 'node3'], label='Kdims')

Dimensions declaring the node indices of each triangle.

property edgepaths#

Returns the EdgePaths by generating a triangle for each simplex.

classmethod from_vertices(data)[source]#

Uses Delauney triangulation to compute triangle simplices for each point.

point_type[source]#

alias of Points

select(selection_specs=None, **selection)[source]#

Allows selecting data by the slices, sets and scalar values along a particular dimension. The indices should be supplied as keywords mapping between the selected dimension and value. Additionally selection_specs (taking the form of a list of type.group.label strings, types or functions) may be supplied, which will ensure the selection is only applied if the specs match the selected object.

class holoviews.element.graphs.layout_chords(*, chord_samples, max_chords, dynamic, group, input_ranges, link_inputs, streams, name)[source]#

Bases: Operation

layout_chords computes the locations of each node on a circle and the chords connecting them. The amount of radial angle devoted to each node and the number of chords are scaled by the value dimension of the Chord element. If the values are integers then the number of chords is directly scaled by the value, if the values are floats then the number of chords are apportioned such that the lowest value edge is given one chord and all other nodes are given nodes proportional to their weight. The max_chords parameter scales the number of chords to be assigned to an edge.

The chords are computed by interpolating a cubic spline from the source to the target node in the graph, the number of samples to interpolate the spline with is given by the chord_samples parameter.

Parameter Definitions


Parameters inherited from:

holoviews.core.operation.Operation: group, dynamic, input_ranges, link_inputs, streams

chord_samples = Integer(bounds=(0, None), default=50, inclusive_bounds=(True, True), label='Chord samples')

Number of samples per chord for the spline interpolation.

max_chords = Integer(default=500, inclusive_bounds=(True, True), label='Max chords')

Maximum number of chords to render.

class holoviews.element.graphs.layout_nodes(*, kwargs, layout, only_nodes, dynamic, group, input_ranges, link_inputs, streams, name)[source]#

Bases: Operation

Accepts a Graph and lays out the corresponding nodes with the supplied networkx layout function. If no layout function is supplied uses a simple circular_layout function. Also supports LayoutAlgorithm function provided in datashader layouts.

Parameter Definitions


Parameters inherited from:

holoviews.core.operation.Operation: group, dynamic, input_ranges, link_inputs, streams

only_nodes = Boolean(default=False, label='Only nodes')

Whether to return Nodes or Graph.

layout = Callable(allow_None=True, label='Layout')

A NetworkX layout function

kwargs = Dict(class_=<class 'dict'>, default={}, label='Kwargs')

Keyword arguments passed to the layout function.