gonum: gonum.org/v1/gonum/graph/layout Index | Files

package layout

import "gonum.org/v1/gonum/graph/layout"

Package layout defines functions for performing graph layout.

Index

Package Files

doc.go eades.go isomap.go layout.go optimizer.go

type EadesR2 Uses

type EadesR2 struct {
    // Updates is the number of updates to perform.
    Updates int

    // Repulsion is the strength of the global
    // repulsive force between nodes in the
    // layout. It corresponds to C3 in the paper.
    Repulsion float64

    // Rate is the gradient descent rate. It
    // corresponds to C4 in the paper.
    Rate float64

    // Theta is the Barnes-Hut theta constant.
    Theta float64

    // Src is the source of randomness used
    // to initialize the nodes' locations. If
    // Src is nil, the global random number
    // generator is used.
    Src rand.Source
    // contains filtered or unexported fields
}

EadesR2 implements the graph layout algorithm essentially as described in "A heuristic for graph drawing", Congressus numerantium 42:149-160. The implementation here uses the Barnes-Hut approximation for global repulsion calculation, and edge weights are considered when calculating adjacent node attraction.

func (*EadesR2) Update Uses

func (u *EadesR2) Update(g graph.Graph, layout LayoutR2) bool

Update is the EadesR2 spatial graph update function.

type GraphR2 Uses

type GraphR2 interface {
    graph.Graph
    LayoutNodeR2(id int64) NodeR2
}

GraphR2 is a graph with planar spatial representation of node positions.

type IsomapR2 Uses

type IsomapR2 struct{}

IsomapR2 implements a graph layout algorithm based on the Isomap non-linear dimensionality reduction method. Coordinates of nodes are computed by finding a Torgerson multidimensional scaling of the shortest path distances between all pairs of node in the graph. The all pair shortest path distances are calculated using the Floyd-Warshall algorithm and so IsomapR2 will not scale to large graphs. Graphs with more than one connected component cannot be laid out by IsomapR2.

func (IsomapR2) Update Uses

func (IsomapR2) Update(g graph.Graph, layout LayoutR2) bool

Update is the IsomapR2 spatial graph update function.

type LayoutR2 Uses

type LayoutR2 interface {
    // IsInitialized returns whether the Layout is initialized.
    IsInitialized() bool

    // SetCoord2 sets the coordinates of the node with the given
    // id to coords.
    SetCoord2(id int64, coords r2.Vec)

    // Coord2 returns the coordinated of the node with the given
    // id in the graph layout.
    Coord2(id int64) r2.Vec
}

LayoutR2 implements graph layout updates and representations.

type NodeR2 Uses

type NodeR2 struct {
    graph.Node
    Coord2 r2.Vec
}

NodeR2 is a graph node with planar spatial representation of its position. A NodeR2 is only valid when the graph.Node is not nil.

type OptimizerR2 Uses

type OptimizerR2 struct {

    // Updater is the function called for each call to Update.
    // It updates the OptimizerR2's spatial distribution of the
    // nodes in the backing graph.
    Updater func(graph.Graph, LayoutR2) bool
    // contains filtered or unexported fields
}

OptimizerR2 is a helper type that holds a graph and layout optimization state.

func NewOptimizerR2 Uses

func NewOptimizerR2(g graph.Graph, update func(graph.Graph, LayoutR2) bool) OptimizerR2

NewOptimizerR2 returns a new layout optimizer. If g implements LayoutR2 the layout will be updated into g, otherwise the OptimizerR2 will hold the graph layout. A nil value for update is a valid no-op layout update function.

func (OptimizerR2) Coord2 Uses

func (g OptimizerR2) Coord2(id int64) r2.Vec

Coord2 returns the location of the node with the given ID. The returned value is only valid if the node exists in the graph.

func (OptimizerR2) Edge Uses

func (g OptimizerR2) Edge(uid, vid int64) graph.Edge

Edge returns the edge from u to v, with IDs uid and vid, if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (OptimizerR2) From Uses

func (g OptimizerR2) From(id int64) graph.Nodes

From returns all nodes that can be reached directly from the node with the given ID.

func (OptimizerR2) HasEdgeBetween Uses

func (g OptimizerR2) HasEdgeBetween(xid, yid int64) bool

HasEdgeBetween returns whether an edge exists between nodes with IDs xid and yid without considering direction.

func (OptimizerR2) LayoutNodeR2 Uses

func (g OptimizerR2) LayoutNodeR2(id int64) NodeR2

LayoutNodeR2 implements the GraphR2 interface.

func (OptimizerR2) Node Uses

func (g OptimizerR2) Node(id int64) graph.Node

Node returns the node with the given ID if it exists in the graph, and nil otherwise.

func (OptimizerR2) Nodes Uses

func (g OptimizerR2) Nodes() graph.Nodes

Nodes returns all the nodes in the graph.

func (OptimizerR2) Update Uses

func (g OptimizerR2) Update() bool

Update updates the locations of the nodes in the graph according to the provided update function. It returns whether the update function is able to further refine the graph's node locations.

Package layout imports 8 packages (graph) and is imported by 1 packages. Updated 2019-09-16. Refresh now. Tools for package owners.