type UndirectedGraph … // NewUndirectedGraph returns an UndirectedGraph with the specified self and absent // edge weight values. func NewUndirectedGraph(self, absent float64) *UndirectedGraph { … } // NewNodeID returns a new unique ID for a node to be added to g. The returned ID does // not become a valid ID in g until it is added to g. func (g *UndirectedGraph) NewNodeID() int { … } // AddNode adds n to the graph. It panics if the added node ID matches an existing node ID. func (g *UndirectedGraph) AddNode(n graph.Node) { … } // RemoveNode removes n 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 (g *UndirectedGraph) RemoveNode(n graph.Node) { … } // SetEdge adds e, an edge from one node to another. If the nodes do not exist, they are added. // It will panic if the IDs of the e.From and e.To are equal. func (g *UndirectedGraph) SetEdge(e graph.Edge) { … } // RemoveEdge removes e from the graph, leaving the terminal nodes. If the edge does not exist // it is a no-op. func (g *UndirectedGraph) RemoveEdge(e graph.Edge) { … } // Node returns the node in the graph with the given ID. func (g *UndirectedGraph) Node(id int) graph.Node { … } // Has returns whether the node exists within the graph. func (g *UndirectedGraph) Has(n graph.Node) bool { … } // Nodes returns all the nodes in the graph. func (g *UndirectedGraph) Nodes() []graph.Node { … } // Edges returns all the edges in the graph. func (g *UndirectedGraph) Edges() []graph.Edge { … } // From returns all nodes in g that can be reached directly from n. func (g *UndirectedGraph) From(n graph.Node) []graph.Node { … } // HasEdgeBetween returns whether an edge exists between nodes x and y. func (g *UndirectedGraph) HasEdgeBetween(x, y graph.Node) bool { … } // 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. func (g *UndirectedGraph) Edge(u, v graph.Node) graph.Edge { … } // EdgeBetween returns the edge between nodes x and y. func (g *UndirectedGraph) EdgeBetween(x, y graph.Node) graph.Edge { … } // Weight returns the weight for the edge between x and y if Edge(x, y) returns a non-nil Edge. // If x and y are the same node or there is no joining edge between the two nodes the weight // value returned is either the graph's absent or self value. Weight returns true if an edge // exists between x and y or if x and y have the same ID, false otherwise. func (g *UndirectedGraph) Weight(x, y graph.Node) (w float64, ok bool) { … } // Degree returns the degree of n in g. func (g *UndirectedGraph) Degree(n graph.Node) int { … }