rename things
This commit is contained in:
@@ -19,35 +19,35 @@ package dot
|
||||
import (
|
||||
"math"
|
||||
|
||||
"scm.dairydemon.net/filifa/gv2adj/cmd/internal/markov"
|
||||
igraph "scm.dairydemon.net/filifa/gv2adj/cmd/internal/graph"
|
||||
|
||||
"gonum.org/v1/gonum/graph"
|
||||
"gonum.org/v1/gonum/graph/multi"
|
||||
)
|
||||
|
||||
// DOTMarkovChain is a graph representing an absorbing Markov chain.
|
||||
type DOTMarkovChain struct {
|
||||
*markov.AbsorbingMarkovChain
|
||||
// DOTDirectedGraph is a graph representing an absorbing Markov chain.
|
||||
type DOTDirectedGraph struct {
|
||||
*igraph.DirectedGraph
|
||||
}
|
||||
|
||||
// NewDOTMarkovChain returns an absorbing Markov chain with no nodes or
|
||||
// NewDOTDirectedGraph returns an absorbing Markov chain with no nodes or
|
||||
// edges.
|
||||
func NewDOTMarkovChain() *DOTMarkovChain {
|
||||
return &DOTMarkovChain{AbsorbingMarkovChain: markov.NewAbsorbingMarkovChain()}
|
||||
func NewDOTDirectedGraph() *DOTDirectedGraph {
|
||||
return &DOTDirectedGraph{DirectedGraph: igraph.NewDirectedGraph()}
|
||||
}
|
||||
|
||||
// NewLine returns a DOT-aware weighted line.
|
||||
func (g *DOTMarkovChain) NewLine(from, to graph.Node) graph.Line {
|
||||
e := g.AbsorbingMarkovChain.NewWeightedLine(from, to, math.NaN()).(multi.WeightedLine)
|
||||
func (g *DOTDirectedGraph) NewLine(from, to graph.Node) graph.Line {
|
||||
e := g.DirectedGraph.NewWeightedLine(from, to, math.NaN()).(multi.WeightedLine)
|
||||
return &weightedLine{WeightedLine: e}
|
||||
}
|
||||
|
||||
// NewNode returns a DOT-aware Node.
|
||||
func (g *DOTMarkovChain) NewNode() graph.Node {
|
||||
return &Node{Node: g.AbsorbingMarkovChain.NewNode()}
|
||||
func (g *DOTDirectedGraph) NewNode() graph.Node {
|
||||
return &Node{Node: g.DirectedGraph.NewNode()}
|
||||
}
|
||||
|
||||
// SetLine adds a DOT-aware weighted line to the Markov chain.
|
||||
func (g *DOTMarkovChain) SetLine(e graph.Line) {
|
||||
g.AbsorbingMarkovChain.SetWeightedLine(e.(*weightedLine))
|
||||
func (g *DOTDirectedGraph) SetLine(e graph.Line) {
|
||||
g.DirectedGraph.SetWeightedLine(e.(*weightedLine))
|
||||
}
|
||||
@@ -14,7 +14,7 @@ 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package markov
|
||||
package graph
|
||||
|
||||
import (
|
||||
"gonum.org/v1/gonum/graph"
|
||||
@@ -23,22 +23,20 @@ import (
|
||||
"gonum.org/v1/gonum/mat"
|
||||
)
|
||||
|
||||
// AbsorbingMarkovChain is a graph representing an absorbing Markov chain. This
|
||||
// embeds a multi.WeightedDirectedGraph (as opposed to
|
||||
// DirectedGraph embeds a multi.WeightedDirectedGraph (as opposed to
|
||||
// simple.WeightedDirectedGraph) to handle self loops.
|
||||
type AbsorbingMarkovChain struct {
|
||||
type DirectedGraph struct {
|
||||
*multi.WeightedDirectedGraph
|
||||
}
|
||||
|
||||
// NewAbsorbingMarkovChain returns an absorbing Markov chain with no nodes or
|
||||
// edges.
|
||||
func NewAbsorbingMarkovChain() *AbsorbingMarkovChain {
|
||||
return &AbsorbingMarkovChain{WeightedDirectedGraph: multi.NewWeightedDirectedGraph()}
|
||||
// NewDirectedGraph returns a graph with no nodes or edges.
|
||||
func NewDirectedGraph() *DirectedGraph {
|
||||
return &DirectedGraph{WeightedDirectedGraph: multi.NewWeightedDirectedGraph()}
|
||||
}
|
||||
|
||||
// AbsorbingNodes returns all the nodes in the Markov chain identified as
|
||||
// absorbing nodes.
|
||||
func (g *AbsorbingMarkovChain) AbsorbingNodes() []graph.Node {
|
||||
func (g *DirectedGraph) AbsorbingNodes() []graph.Node {
|
||||
absorbingNodes := make([]graph.Node, 0)
|
||||
for nodes := g.Nodes(); nodes.Next(); {
|
||||
u := nodes.Node()
|
||||
@@ -58,7 +56,7 @@ func (g *AbsorbingMarkovChain) AbsorbingNodes() []graph.Node {
|
||||
}
|
||||
|
||||
// AdjacencyMatrix returns the graph's adjacency matrix.
|
||||
func (g *AbsorbingMarkovChain) AdjacencyMatrix() *mat.Dense {
|
||||
func (g *DirectedGraph) AdjacencyMatrix() *mat.Dense {
|
||||
adj := simple.NewDirectedMatrix(g.Nodes().Len(), 0, 0, 0)
|
||||
for edges := g.WeightedEdges(); edges.Next(); {
|
||||
e := edges.WeightedEdge()
|
||||
Reference in New Issue
Block a user