Documentation
¶
Overview ¶
Package graphprac provides helper routines for short practical in graph analysis.
Index ¶
- func Betweenness(g *Graph)
- func Clique(g *Graph, k int)
- func Closeness(g *Graph)
- func Communities(g *Graph, resolution float64)
- func DOT(g graph.Graph) string
- func Draw(g graph.Graph, format string) (string, error)
- func EdgeBetweenness(g *Graph)
- func Farness(g *Graph)
- func Induce(g *Graph, by []*Node) graph.Graph
- func PageRank(g *Graph, damp, tol float64)
- type Attributes
- type Edge
- type Graph
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Betweenness ¶
func Betweenness(g *Graph)
Betweenness performs a betweenness centrality analysis on g.
The betweenness centrality value is written into the "betweenness" attribute of each node.
func Clique ¶
Clique performs a maximal clique analysis on g where cliques must be k-cliques or larger.
The clique membership values are written as a comma-separated list into the "clique" attribute of each node and the number of cliques a node is a member of is written into "clique_count".
func Closeness ¶
func Closeness(g *Graph)
Closeness performs a closeness centrality analysis on g.
The closeness centrality value is written into the "closeness" attribute of each node.
func Communities ¶
Communities performs a community modularisation of the graph g at the specified resolution.
The community identity value is written into the "community" attribute of each node.
func Draw ¶
Draw renders the graph as an SVG using the GraphViz command in format. The format parameter can be one of "dot", "neato", "fdp" and "sfdp". See https://www.graphviz.org/ for a description of these commands.
func EdgeBetweenness ¶
func EdgeBetweenness(g *Graph)
EdgeBetweenness performs an edge betweenness centrality analysis on g.
The edge betweenness centrality value is written into the "edge_betweenness" attribute of each edge.
func Farness ¶
func Farness(g *Graph)
Farness performs a farness centrality analysis on g.
The farness centrality value is written into the "farness" attribute of each node.
Types ¶
type Attributes ¶
Attributes is a type to help handle DOT attributes.
func (Attributes) Attributes ¶
func (a Attributes) Attributes() []encoding.Attribute
Attributes returns the complete list of attributes.
func (Attributes) DOTAttributes ¶
func (a Attributes) DOTAttributes() []encoding.Attribute
DOTAttributes returns the DOT attributes for the receiver.
func (Attributes) Get ¶
func (a Attributes) Get(attr string) string
Get returns the value of the given attribute. If the attribute is not set, the empty string is returned.
func (*Attributes) SetAttribute ¶
func (a *Attributes) SetAttribute(attr encoding.Attribute) error
Set sets the given attribute to the specified value. If the attr Value field is the empty string, the attribute is unset.
type Edge ¶
type Edge struct {
F, T *Node
Attributes
}
Edge is a graph edge able to handle DOT attributes.
func EdgesByAttribute ¶
EdgesByAttribute return a slice of edges sorted descending by the given attribute.
func (*Edge) ReversedEdge ¶
ReversedEdge returns a copy of the edge with the 'from' and 'to' nodes swapped.
type Graph ¶
type Graph struct { *simple.UndirectedGraph GraphAttrs, NodeAttrs, EdgeAttrs Attributes }
Graph is a general undirected graph with node and edge attributes.
func (*Graph) DOTAttributers ¶
func (g *Graph) DOTAttributers() (graph, node, edge encoding.Attributer)
DOTAttributers returns the global DOT attributes for the graph.
func (*Graph) NewEdge ¶
NewEdge adds a new edge from the source to the destination node to the graph, or returns the existing edge if already present.
type Node ¶
type Node struct { NodeID int64 Name string Attributes }
Node is a graph node able to handle DOT attributes.
func NodesByAttribute ¶
NodesByAttribute return a slice of nodes sorted descending by the given attribute. Only float64 attributes are handled by this function.