/* 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" ) // DirectedGraph embeds a multi.WeightedDirectedGraph (as opposed to // simple.WeightedDirectedGraph) to handle self loops. type WeightedDirectedGraph struct { *multi.WeightedDirectedGraph } // NewDirectedGraph returns a graph with no nodes or edges. func NewWeightedDirectedGraph() *WeightedDirectedGraph { return &WeightedDirectedGraph{WeightedDirectedGraph: multi.NewWeightedDirectedGraph()} } // AdjacencyMatrix returns the graph's adjacency matrix. func (g *WeightedDirectedGraph) AdjacencyMatrix() *mat.Dense { adj := simple.NewDirectedMatrix(g.Nodes().Len(), 0, 0, 0) matrix := toAdjMatrix(g, adj) return matrix }