gonum.org/v1/gonum@v0.14.0/graph/formats/rdf/graph_export_test.go (about) 1 // Copyright ©2022 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package rdf 6 7 import "gonum.org/v1/gonum/graph" 8 9 var ( 10 g *Graph 11 12 _ graph.Graph = g 13 _ graph.Directed = g 14 _ graph.Multigraph = g 15 _ graph.DirectedMultigraph = g 16 _ graph.NodeAdder = g 17 _ graph.NodeRemover = g 18 _ graph.LineAdder = g 19 _ graph.LineRemover = g 20 ) 21 22 // AddNode adds n to the graph. It panics if the added node ID matches an existing node ID. 23 func (g *Graph) AddNode(n graph.Node) { 24 g.addNode(n) 25 } 26 27 // NewLine returns a new Line from the source to the destination node. 28 // The returned Line will have a graph-unique ID. 29 // The Line's ID does not become valid in g until the Line is added to g. 30 func (g *Graph) NewLine(from, to graph.Node) graph.Line { 31 return g.newLine(from, to) 32 } 33 34 // NewNode returns a new unique Node to be added to g. The Node's ID does 35 // not become valid in g until the Node is added to g. 36 func (g *Graph) NewNode() graph.Node { 37 return g.newNode() 38 } 39 40 // RemoveLine removes the line with the given end point and line IDs from the graph, leaving 41 // the terminal nodes. If the line does not exist it is a no-op. 42 func (g *Graph) RemoveLine(fid, tid, id int64) { 43 g.removeLine(fid, tid, id) 44 } 45 46 // RemoveNode removes the node with the given ID from the graph, as well as any edges attached 47 // to it. If the node is not in the graph it is a no-op. 48 func (g *Graph) RemoveNode(id int64) { 49 g.removeNode(id) 50 } 51 52 // SetLine adds l, a line from one node to another. If the nodes do not exist, they are added 53 // and are set to the nodes of the line otherwise. 54 func (g *Graph) SetLine(l graph.Line) { 55 g.setLine(l) 56 }