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

package multi

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

Package multi provides a suite of multigraph implementations satisfying the gonum/graph interfaces.

All types in multi return the graph.Empty value for empty iterators.

Index

Package Files

directed.go doc.go multi.go undirected.go weighted_directed.go weighted_undirected.go

type DirectedGraph Uses

type DirectedGraph struct {
    // contains filtered or unexported fields
}

DirectedGraph implements a generalized directed graph.

func NewDirectedGraph Uses

func NewDirectedGraph() *DirectedGraph

NewDirectedGraph returns a DirectedGraph.

func (*DirectedGraph) AddNode Uses

func (g *DirectedGraph) AddNode(n graph.Node)

AddNode adds n to the graph. It panics if the added node ID matches an existing node ID.

func (*DirectedGraph) Edge Uses

func (g *DirectedGraph) Edge(uid, vid int64) graph.Edge

Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method. The returned graph.Edge is a multi.Edge if an edge exists.

func (*DirectedGraph) Edges Uses

func (g *DirectedGraph) Edges() graph.Edges

Edges returns all the edges in the graph. Each edge in the returned slice is a multi.Edge.

func (*DirectedGraph) From Uses

func (g *DirectedGraph) From(id int64) graph.Nodes

From returns all nodes in g that can be reached directly from n.

func (*DirectedGraph) HasEdgeBetween Uses

func (g *DirectedGraph) HasEdgeBetween(xid, yid int64) bool

HasEdgeBetween returns whether an edge exists between nodes x and y without considering direction.

func (*DirectedGraph) HasEdgeFromTo Uses

func (g *DirectedGraph) HasEdgeFromTo(uid, vid int64) bool

HasEdgeFromTo returns whether an edge exists in the graph from u to v.

func (*DirectedGraph) Lines Uses

func (g *DirectedGraph) Lines(uid, vid int64) graph.Lines

Lines returns the lines from u to v if such any such lines exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (*DirectedGraph) NewLine Uses

func (g *DirectedGraph) NewLine(from, to graph.Node) graph.Line

NewLine returns a new Line from the source to the destination node. The returned Line will have a graph-unique ID. The Line's ID does not become valid in g until the Line is added to g.

func (*DirectedGraph) NewNode Uses

func (g *DirectedGraph) NewNode() graph.Node

NewNode returns a new unique Node to be added to g. The Node's ID does not become valid in g until the Node is added to g.

func (*DirectedGraph) Node Uses

func (g *DirectedGraph) Node(id int64) graph.Node

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

func (*DirectedGraph) Nodes Uses

func (g *DirectedGraph) Nodes() graph.Nodes

Nodes returns all the nodes in the graph.

func (*DirectedGraph) RemoveLine Uses

func (g *DirectedGraph) RemoveLine(fid, tid, id int64)

RemoveLine removes the line with the given end point and line IDs from the graph, leaving the terminal nodes. If the line does not exist it is a no-op.

func (*DirectedGraph) RemoveNode Uses

func (g *DirectedGraph) RemoveNode(id int64)

RemoveNode removes the node with the given ID from the graph, as well as any edges attached to it. If the node is not in the graph it is a no-op.

func (*DirectedGraph) SetLine Uses

func (g *DirectedGraph) SetLine(l graph.Line)

SetLine adds l, a line from one node to another. If the nodes do not exist, they are added and are set to the nodes of the line otherwise.

func (*DirectedGraph) To Uses

func (g *DirectedGraph) To(id int64) graph.Nodes

To returns all nodes in g that can reach directly to n.

type Edge Uses

type Edge struct {
    F, T graph.Node

    graph.Lines
}

Edge is a collection of multigraph edges sharing end points.

func (Edge) From Uses

func (e Edge) From() graph.Node

From returns the from-node of the edge.

func (Edge) ReversedEdge Uses

func (e Edge) ReversedEdge() graph.Edge

ReversedEdge returns a new Edge with the F and T fields swapped.

func (Edge) To Uses

func (e Edge) To() graph.Node

To returns the to-node of the edge.

type Line Uses

type Line struct {
    F, T graph.Node

    UID int64
}

Line is a multigraph edge.

func (Line) From Uses

func (l Line) From() graph.Node

From returns the from-node of the line.

func (Line) ID Uses

func (l Line) ID() int64

ID returns the ID of the line.

func (Line) ReversedLine Uses

func (l Line) ReversedLine() graph.Line

ReversedLine returns a new Line with the F and T fields swapped. The UID of the new Line is the same as the UID of the receiver. The Lines within the Edge are not altered.

func (Line) To Uses

func (l Line) To() graph.Node

To returns the to-node of the line.

type Node Uses

type Node int64

Node is a simple graph node.

func (Node) ID Uses

func (n Node) ID() int64

ID returns the ID number of the node.

type UndirectedGraph Uses

type UndirectedGraph struct {
    // contains filtered or unexported fields
}

UndirectedGraph implements a generalized undirected graph.

func NewUndirectedGraph Uses

func NewUndirectedGraph() *UndirectedGraph

NewUndirectedGraph returns an UndirectedGraph.

func (*UndirectedGraph) AddNode Uses

func (g *UndirectedGraph) AddNode(n graph.Node)

AddNode adds n to the graph. It panics if the added node ID matches an existing node ID.

func (*UndirectedGraph) Edge Uses

func (g *UndirectedGraph) Edge(uid, vid int64) graph.Edge

Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method. The returned graph.Edge is a multi.Edge if an edge exists.

func (*UndirectedGraph) EdgeBetween Uses

func (g *UndirectedGraph) EdgeBetween(xid, yid int64) graph.Edge

EdgeBetween returns the edge between nodes x and y.

func (*UndirectedGraph) Edges Uses

func (g *UndirectedGraph) Edges() graph.Edges

Edges returns all the edges in the graph. Each edge in the returned slice is a multi.Edge.

func (*UndirectedGraph) From Uses

func (g *UndirectedGraph) From(id int64) graph.Nodes

From returns all nodes in g that can be reached directly from n.

func (*UndirectedGraph) HasEdgeBetween Uses

func (g *UndirectedGraph) HasEdgeBetween(xid, yid int64) bool

HasEdgeBetween returns whether an edge exists between nodes x and y.

func (*UndirectedGraph) Lines Uses

func (g *UndirectedGraph) Lines(uid, vid int64) graph.Lines

Lines returns the lines from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (*UndirectedGraph) LinesBetween Uses

func (g *UndirectedGraph) LinesBetween(xid, yid int64) graph.Lines

LinesBetween returns the lines between nodes x and y.

func (*UndirectedGraph) NewLine Uses

func (g *UndirectedGraph) NewLine(from, to graph.Node) graph.Line

NewLine returns a new Line from the source to the destination node. The returned Line will have a graph-unique ID. The Line's ID does not become valid in g until the Line is added to g.

func (*UndirectedGraph) NewNode Uses

func (g *UndirectedGraph) NewNode() graph.Node

NewNode returns a new unique Node to be added to g. The Node's ID does not become valid in g until the Node is added to g.

func (*UndirectedGraph) Node Uses

func (g *UndirectedGraph) Node(id int64) graph.Node

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

func (*UndirectedGraph) Nodes Uses

func (g *UndirectedGraph) Nodes() graph.Nodes

Nodes returns all the nodes in the graph.

func (*UndirectedGraph) RemoveLine Uses

func (g *UndirectedGraph) RemoveLine(fid, tid, id int64)

RemoveLine removes the line with the given end point and line Ids from the graph, leaving the terminal nodes. If the line does not exist it is a no-op.

func (*UndirectedGraph) RemoveNode Uses

func (g *UndirectedGraph) RemoveNode(id int64)

RemoveNode removes the node with the given ID from the graph, as well as any edges attached to it. If the node is not in the graph it is a no-op.

func (*UndirectedGraph) SetLine Uses

func (g *UndirectedGraph) SetLine(l graph.Line)

SetLine adds l, a line from one node to another. If the nodes do not exist, they are added and are set to the nodes of the line otherwise.

type WeightedDirectedGraph Uses

type WeightedDirectedGraph struct {
    // EdgeWeightFunc is used to provide
    // the WeightFunc function for WeightedEdge
    // values returned by the graph.
    // WeightFunc must accept a nil input.
    EdgeWeightFunc func(graph.WeightedLines) float64
    // contains filtered or unexported fields
}

WeightedDirectedGraph implements a generalized directed graph.

func NewWeightedDirectedGraph Uses

func NewWeightedDirectedGraph() *WeightedDirectedGraph

NewWeightedDirectedGraph returns a WeightedDirectedGraph.

func (*WeightedDirectedGraph) AddNode Uses

func (g *WeightedDirectedGraph) AddNode(n graph.Node)

AddNode adds n to the graph. It panics if the added node ID matches an existing node ID.

func (*WeightedDirectedGraph) Edge Uses

func (g *WeightedDirectedGraph) Edge(uid, vid int64) graph.Edge

Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method. The returned graph.Edge is a multi.WeightedEdge if an edge exists.

func (*WeightedDirectedGraph) Edges Uses

func (g *WeightedDirectedGraph) Edges() graph.Edges

Edges returns all the edges in the graph. Each edge in the returned slice is a multi.WeightedEdge.

func (*WeightedDirectedGraph) From Uses

func (g *WeightedDirectedGraph) From(id int64) graph.Nodes

From returns all nodes in g that can be reached directly from n.

func (*WeightedDirectedGraph) HasEdgeBetween Uses

func (g *WeightedDirectedGraph) HasEdgeBetween(xid, yid int64) bool

HasEdgeBetween returns whether an edge exists between nodes x and y without considering direction.

func (*WeightedDirectedGraph) HasEdgeFromTo Uses

func (g *WeightedDirectedGraph) HasEdgeFromTo(uid, vid int64) bool

HasEdgeFromTo returns whether an edge exists in the graph from u to v.

func (*WeightedDirectedGraph) Lines Uses

func (g *WeightedDirectedGraph) Lines(uid, vid int64) graph.Lines

Lines returns the lines from u to v if such any such lines exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (*WeightedDirectedGraph) NewNode Uses

func (g *WeightedDirectedGraph) NewNode() graph.Node

NewNode returns a new unique Node to be added to g. The Node's ID does not become valid in g until the Node is added to g.

func (*WeightedDirectedGraph) NewWeightedLine Uses

func (g *WeightedDirectedGraph) NewWeightedLine(from, to graph.Node, weight float64) graph.WeightedLine

NewWeightedLine returns a new WeightedLine from the source to the destination node. The returned WeightedLine will have a graph-unique ID. The Line's ID does not become valid in g until the Line is added to g.

func (*WeightedDirectedGraph) Node Uses

func (g *WeightedDirectedGraph) Node(id int64) graph.Node

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

func (*WeightedDirectedGraph) Nodes Uses

func (g *WeightedDirectedGraph) Nodes() graph.Nodes

Nodes returns all the nodes in the graph.

func (*WeightedDirectedGraph) RemoveLine Uses

func (g *WeightedDirectedGraph) RemoveLine(fid, tid, id int64)

RemoveLine removes the line with the given end point and line IDs from the graph, leaving the terminal nodes. If the line does not exist it is a no-op.

func (*WeightedDirectedGraph) RemoveNode Uses

func (g *WeightedDirectedGraph) RemoveNode(id int64)

RemoveNode removes the node with the given ID from the graph, as well as any edges attached to it. If the node is not in the graph it is a no-op.

func (*WeightedDirectedGraph) SetWeightedLine Uses

func (g *WeightedDirectedGraph) SetWeightedLine(l graph.WeightedLine)

SetWeightedLine adds l, a line from one node to another. If the nodes do not exist, they are added and are set to the nodes of the line otherwise.

func (*WeightedDirectedGraph) To Uses

func (g *WeightedDirectedGraph) To(id int64) graph.Nodes

To returns all nodes in g that can reach directly to n.

func (*WeightedDirectedGraph) Weight Uses

func (g *WeightedDirectedGraph) Weight(uid, vid int64) (w float64, ok bool)

Weight returns the weight for the lines between x and y summarised by the receiver's EdgeWeightFunc. Weight returns true if an edge exists between x and y, false otherwise.

func (*WeightedDirectedGraph) WeightedEdge Uses

func (g *WeightedDirectedGraph) WeightedEdge(uid, vid int64) graph.WeightedEdge

WeightedEdge returns the weighted edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method. The returned graph.WeightedEdge is a multi.WeightedEdge if an edge exists.

func (*WeightedDirectedGraph) WeightedEdges Uses

func (g *WeightedDirectedGraph) WeightedEdges() graph.WeightedEdges

WeightedEdges returns all the edges in the graph. Each edge in the returned slice is a multi.WeightedEdge.

func (*WeightedDirectedGraph) WeightedLines Uses

func (g *WeightedDirectedGraph) WeightedLines(uid, vid int64) graph.WeightedLines

WeightedLines returns the weighted lines from u to v if such any such lines exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

type WeightedEdge Uses

type WeightedEdge struct {
    F, T graph.Node

    graph.WeightedLines

    // WeightFunc calculates the aggregate
    // weight of the lines in Lines. If
    // WeightFunc is nil, the sum of weights
    // is used as the edge weight.
    // The graph.WeightedLines can be expected
    // to be positioned at the first line of
    // the iterator on entry and must be
    // Reset before exit.
    // WeightFunc must accept a nil input.
    WeightFunc func(graph.WeightedLines) float64
}

WeightedEdge is a collection of weighted multigraph edges sharing end points.

func (WeightedEdge) From Uses

func (e WeightedEdge) From() graph.Node

From returns the from-node of the edge.

func (WeightedEdge) ReversedEdge Uses

func (e WeightedEdge) ReversedEdge() graph.Edge

ReversedEdge returns a new Edge with the F and T fields swapped. The Lines within the WeightedEdge are not altered.

func (WeightedEdge) To Uses

func (e WeightedEdge) To() graph.Node

To returns the to-node of the edge.

func (WeightedEdge) Weight Uses

func (e WeightedEdge) Weight() float64

Weight returns the weight of the edge. Weight uses WeightFunc field to calculate the weight, so the WeightedLines field is expected to be positioned at the first line and is reset before Weight returns.

type WeightedLine Uses

type WeightedLine struct {
    F, T graph.Node
    W    float64

    UID int64
}

WeightedLine is a weighted multigraph edge.

func (WeightedLine) From Uses

func (l WeightedLine) From() graph.Node

From returns the from-node of the line.

func (WeightedLine) ID Uses

func (l WeightedLine) ID() int64

ID returns the ID of the line.

func (WeightedLine) ReversedLine Uses

func (l WeightedLine) ReversedLine() graph.Line

ReversedLine returns a new Line with the F and T fields swapped. The UID and W of the new Line are the same as the UID and W of the receiver.

func (WeightedLine) To Uses

func (l WeightedLine) To() graph.Node

To returns the to-node of the line.

func (WeightedLine) Weight Uses

func (l WeightedLine) Weight() float64

Weight returns the weight of the edge.

type WeightedUndirectedGraph Uses

type WeightedUndirectedGraph struct {
    // EdgeWEightFunc is used to provide
    // the WeightFunc function for WeightedEdge
    // values returned by the graph.
    // WeightFunc must accept a nil input.
    EdgeWeightFunc func(graph.WeightedLines) float64
    // contains filtered or unexported fields
}

WeightedUndirectedGraph implements a generalized undirected graph.

func NewWeightedUndirectedGraph Uses

func NewWeightedUndirectedGraph() *WeightedUndirectedGraph

NewWeightedUndirectedGraph returns an WeightedUndirectedGraph.

func (*WeightedUndirectedGraph) AddNode Uses

func (g *WeightedUndirectedGraph) AddNode(n graph.Node)

AddNode adds n to the graph. It panics if the added node ID matches an existing node ID.

func (*WeightedUndirectedGraph) Edge Uses

func (g *WeightedUndirectedGraph) Edge(uid, vid int64) graph.Edge

Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method. The returned graph.Edge is a multi.WeightedEdge if an edge exists.

func (*WeightedUndirectedGraph) EdgeBetween Uses

func (g *WeightedUndirectedGraph) EdgeBetween(xid, yid int64) graph.Edge

EdgeBetween returns the edge between nodes x and y.

func (*WeightedUndirectedGraph) Edges Uses

func (g *WeightedUndirectedGraph) Edges() graph.Edges

Edges returns all the edges in the graph. Each edge in the returned slice is a multi.Edge.

func (*WeightedUndirectedGraph) From Uses

func (g *WeightedUndirectedGraph) From(id int64) graph.Nodes

From returns all nodes in g that can be reached directly from n.

func (*WeightedUndirectedGraph) HasEdgeBetween Uses

func (g *WeightedUndirectedGraph) HasEdgeBetween(xid, yid int64) bool

HasEdgeBetween returns whether an edge exists between nodes x and y.

func (*WeightedUndirectedGraph) Lines Uses

func (g *WeightedUndirectedGraph) Lines(uid, vid int64) graph.Lines

Lines returns the lines from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (*WeightedUndirectedGraph) LinesBetween Uses

func (g *WeightedUndirectedGraph) LinesBetween(xid, yid int64) graph.Lines

LinesBetween returns the lines between nodes x and y.

func (*WeightedUndirectedGraph) NewNode Uses

func (g *WeightedUndirectedGraph) NewNode() graph.Node

NewNode returns a new unique Node to be added to g. The Node's ID does not become valid in g until the Node is added to g.

func (*WeightedUndirectedGraph) NewWeightedLine Uses

func (g *WeightedUndirectedGraph) NewWeightedLine(from, to graph.Node, weight float64) graph.WeightedLine

NewWeightedLine returns a new WeightedLine from the source to the destination node. The returned WeightedLine will have a graph-unique ID. The Line's ID does not become valid in g until the Line is added to g.

func (*WeightedUndirectedGraph) Node Uses

func (g *WeightedUndirectedGraph) Node(id int64) graph.Node

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

func (*WeightedUndirectedGraph) Nodes Uses

func (g *WeightedUndirectedGraph) Nodes() graph.Nodes

Nodes returns all the nodes in the graph.

func (*WeightedUndirectedGraph) RemoveLine Uses

func (g *WeightedUndirectedGraph) RemoveLine(fid, tid, id int64)

RemoveLine removes the line with the given end point and line IDs from the graph, leaving the terminal nodes. If the line does not exist it is a no-op.

func (*WeightedUndirectedGraph) RemoveNode Uses

func (g *WeightedUndirectedGraph) RemoveNode(id int64)

RemoveNode removes the node with the given ID from the graph, as well as any edges attached to it. If the node is not in the graph it is a no-op.

func (*WeightedUndirectedGraph) SetWeightedLine Uses

func (g *WeightedUndirectedGraph) SetWeightedLine(l graph.WeightedLine)

SetWeightedLine adds l, a line from one node to another. If the nodes do not exist, they are added and are set to the nodes of the line otherwise.

func (*WeightedUndirectedGraph) Weight Uses

func (g *WeightedUndirectedGraph) Weight(xid, yid int64) (w float64, ok bool)

Weight returns the weight for the lines between x and y summarised by the receiver's EdgeWeightFunc. Weight returns true if an edge exists between x and y, false otherwise.

func (*WeightedUndirectedGraph) WeightedEdge Uses

func (g *WeightedUndirectedGraph) WeightedEdge(uid, vid int64) graph.WeightedEdge

WeightedEdge returns the weighted edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method. The returned graph.WeightedEdge is a multi.WeightedEdge if an edge exists.

func (*WeightedUndirectedGraph) WeightedEdgeBetween Uses

func (g *WeightedUndirectedGraph) WeightedEdgeBetween(xid, yid int64) graph.WeightedEdge

WeightedEdgeBetween returns the weighted edge between nodes x and y.

func (*WeightedUndirectedGraph) WeightedEdges Uses

func (g *WeightedUndirectedGraph) WeightedEdges() graph.WeightedEdges

WeightedEdges returns all the edges in the graph. Each edge in the returned slice is a multi.Edge.

func (*WeightedUndirectedGraph) WeightedLines Uses

func (g *WeightedUndirectedGraph) WeightedLines(uid, vid int64) graph.WeightedLines

WeightedLines returns the lines from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (*WeightedUndirectedGraph) WeightedLinesBetween Uses

func (g *WeightedUndirectedGraph) WeightedLinesBetween(xid, yid int64) graph.WeightedLines

WeightedLinesBetween returns the lines between nodes x and y.

Package multi imports 4 packages (graph) and is imported by 2 packages. Updated 2019-03-16. Refresh now. Tools for package owners.