Forces#

Forces for controlling the layout of ipyforcegraph graphs.

Using documentation from:

class ipyforcegraph.behaviors.forces.Center(**kwargs)[source]#

Bases: BaseD3Force

The centering force translates nodes uniformly so that the mean position of all nodes (center of mass if all nodes have equal weight) is at the given position (x, y, z).

d3/d3-force

Public constructor

x Float(None)#

the x-coordinate of the position to center the nodes on

y Float(None)#

the y-coordinate of the position to center the nodes on

z Float(None)#

the z-coordinate of the position to center the nodes on (only applies to ForceGraph3D)

class ipyforcegraph.behaviors.forces.Cluster(key=None, *args, **kwargs)[source]#

Bases: BaseD3Force

A force type that attracts nodes toward a set of cluster centers.

vasturiano/d3-force-cluster-3d

Public constructor

inertia Float(None)#

lower values result in cluster center nodes more easily pulled around by other nodes in the cluster.

key Union(None)#

a cluster key to which a node belongs. Context takes node.

radius Union(None)#

the radius of a cluster. Context takes cluster, node, key, and nodes.

strength Float(None)#

the strength of the force

x Union(None)#

the x-coordinate of a cluster. Context takes cluster, node, key, and nodes.

y Union(None)#

the y-coordinate of a cluster. Context takes cluster, node, key, and nodes.

z Union(None)#

the z-coordinate of a cluster. Context takes cluster, node, key, and nodes.

class ipyforcegraph.behaviors.forces.Collision(**kwargs)[source]#

Bases: BaseD3Force

The collision force treats nodes as circles with a given radius, rather than points and prevents nodes from overlapping.

d3/d3-force

Public constructor

radius Union(None)#

The radius of collision by node. Context takes node

strength Float(None)#

the strength of the force

class ipyforcegraph.behaviors.forces.DAG(mode=None, *args, **kwargs)[source]#

Bases: BaseD3Force

This behavior enforces constraints for displaying Directed Acyclic Graphs.

vasturiano/force-graph

Public constructor

class Mode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

The layout orientation options for the DAG.

bottom_up Float(None)#
left_right Float(None)#
off Float(None)#
radial_in Float(None)#
radial_out Float(None)#
right_left Float(None)#
top_down Float(None)#
level_distance Float(None)#

distance between DAG levels

mode Enum(None)#

DAG constraint layout mode/direction

node_filter Union(True)#

whether node is part of the DAG layout

class ipyforcegraph.behaviors.forces.GraphForces(forces=None, *args, **kwargs)[source]#

Bases: Behavior

Customize ForceGraph force simulation.

These also apply to ForceGraph3D

For more, see the frontend documentation on vasturiano/force-graph

Public constructor

alpha_decay Float(0.0228)#

simulation intensity decay parameter

alpha_min Float(0.0)#

simulation alpha min parameter

cooldown_ticks Int(-1)#

frames to render before stopping and freezing the layout engine. Values less than zero will be translated to Infinity

forces Dict()#

named forces. Set a name None to remove a force: By default, ForceGraph has link, charge, and center

velocity_decay Float(0.4)#

nodes’ velocity decay that simulates the medium resistance

warmup_ticks Int(0)#

layout engine cycles to dry-run at ignition before starting to render

Bases: BaseD3Force

This Link Force is between two nodes that share an edge.

d3/d3-force

Public constructor

distance Union(None)#

the ‘desired’ distance of a link. Context takes link

strength Union(None)#

the strength of a link in reaching its desired length. Context takes link

class ipyforcegraph.behaviors.forces.ManyBody(**kwargs)[source]#

Bases: BaseD3Force

The many-body (or n-body) force applies mutually amongst all nodes. It can be used to simulate gravity (attraction) if the strength is positive, or electrostatic charge (repulsion) if the strength is negative. This implementation uses quadtrees and the Barnes–Hut approximation to greatly improve performance; the accuracy can be customized using the theta parameter.

d3/d3-force

Public constructor

distance_max Float(None)#

the maximum distance between nodes over which this force is considered

distance_min Float(None)#

the minimum distance between nodes over which this force is considered

strength Union(0)#

a nunjucks template to use to calculate strength. Context takes node

theta Float(None)#

the Barnes-Hut approximation criterion

class ipyforcegraph.behaviors.forces.Radial(**kwargs)[source]#

Bases: BaseD3Force

The radial positioning force create a force towards a circle of the specified radius centered at (x, y).

d3/d3-force

Public constructor

radius Union(None)#

radius of the force. Context takes node

strength Union(0)#

the strength of the force. Context takes node

x Float(None)#

the x-coordinate of the centering position

y Float(None)#

the y-coordinate of the centering position

z Float(None)#

the z-coordinate of the centering position

class ipyforcegraph.behaviors.forces.X(**kwargs)[source]#

Bases: BaseD3Force

The X position force push nodes towards a desired position along the given dimension with a configurable strength.

d3/d3-force

Public constructor

strength Union(0)#

the strength of the force. Context takes node

x Union(None)#

the x-coordinate of the centering position to the specified number. Context takes node.

class ipyforcegraph.behaviors.forces.Y(**kwargs)[source]#

Bases: BaseD3Force

The Y position force push nodes towards a desired position along the given dimension with a configurable strength.

d3/d3-force

Public constructor

strength Union(0)#

the strength of the force. Context takes node

y Union(None)#

the y-coordinate of the centering position. Context takes node.

class ipyforcegraph.behaviors.forces.Z(**kwargs)[source]#

Bases: BaseD3Force

The Z position force push nodes towards a desired position along the given dimension with a configurable strength.

Note

Only affects ForceGraph3D.

d3/d3-force

Public constructor

strength Union(0)#

the strength of the force. Context takes node

z Union(None)#

the z-coordinate of the centering position. Context takes node.