parse differently depending on graph type

This commit is contained in:
filifa
2025-05-08 23:45:13 -04:00
parent 339fdc0bcf
commit 2013e26fb9
3 changed files with 19 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ import (
type WeightedGraph interface {
graph.Weighted
graph.WeightedMultigraph
graph.WeightedMultigraphBuilder
WeightedEdges() graph.WeightedEdges

View File

@@ -41,7 +41,7 @@ func NewDOTUndirectedGraph(weightAttr string) DOTWeightedGraph {
}
// NewLine returns a DOT-aware weighted line.
func (g *DOTWeightedGraph) NewLine(from, to graph.Node) graph.Line {
func (g DOTWeightedGraph) NewLine(from, to graph.Node) graph.Line {
var defaultWeight float64
if g.WeightAttribute == "" {
defaultWeight = 1
@@ -54,11 +54,11 @@ func (g *DOTWeightedGraph) NewLine(from, to graph.Node) graph.Line {
}
// NewNode returns a DOT-aware Node.
func (g *DOTWeightedGraph) NewNode() graph.Node {
func (g DOTWeightedGraph) NewNode() graph.Node {
return &Node{Node: g.WeightedGraph.NewNode()}
}
// SetLine adds a DOT-aware weighted line to the graph.
func (g *DOTWeightedGraph) SetLine(e graph.Line) {
func (g DOTWeightedGraph) SetLine(e graph.Line) {
g.WeightedGraph.SetWeightedLine(e.(*weightedLine))
}