/* Copyright © 2025 filifa This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package graph import ( "gonum.org/v1/gonum/graph/multi" "gonum.org/v1/gonum/graph/simple" "gonum.org/v1/gonum/mat" ) // UndirectedGraph embeds a multi.WeightedUndirectedGraph (as opposed to // simple.WeightedUndirectedGraph) to handle self loops. type WeightedUndirectedGraph struct { *multi.WeightedUndirectedGraph } // NewUndirectedGraph returns a graph with no nodes or edges. func NewWeightedUndirectedGraph() *WeightedUndirectedGraph { return &WeightedUndirectedGraph{WeightedUndirectedGraph: multi.NewWeightedUndirectedGraph()} } // AdjacencyMatrix returns the graph's adjacency matrix. func (g *WeightedUndirectedGraph) AdjacencyMatrix() *mat.Dense { adj := simple.NewUndirectedMatrix(g.Nodes().Len(), 0, 0, 0) matrix := toAdjMatrix(g, adj) return matrix }