61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package day25
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestReadFileExample(t *testing.T) {
|
|
filename := "example"
|
|
g := ReadGraphFile(filename)
|
|
t.Logf("read graph %+v", g)
|
|
}
|
|
|
|
func TestRemoveEdge(t *testing.T) {
|
|
filename := "example"
|
|
g := ReadGraphFile(filename)
|
|
t.Logf("read graph %+v", g)
|
|
|
|
g.RemoveEdge("bvb", "hfx")
|
|
t.Logf("after removing bvb-hfv %+v", g)
|
|
}
|
|
|
|
func TestCreateExampleMermaid(t *testing.T) {
|
|
filename := "example"
|
|
g := ReadGraphFile(filename)
|
|
|
|
g.SaveAsMermaid("example-graph.mmd")
|
|
}
|
|
|
|
func TestComponentOnInitial(t *testing.T) {
|
|
// should be all nodes
|
|
filename := "example"
|
|
g := ReadGraphFile(filename)
|
|
comp := g.ComponentFrom("bvb")
|
|
t.Logf("got component %+v", comp)
|
|
if comp.Cardinality() != len(g.Nodes) {
|
|
t.Errorf("should have same size!")
|
|
}
|
|
}
|
|
|
|
func TestComponentOnMini(t *testing.T) {
|
|
// should be all nodes
|
|
filename := "example2"
|
|
g := ReadGraphFile(filename)
|
|
comp := g.ComponentFrom("jqt")
|
|
t.Logf("got component %+v", comp)
|
|
if comp.Cardinality() == len(g.Nodes) {
|
|
t.Errorf("should have different size!")
|
|
}
|
|
}
|
|
|
|
func TestRemoveAllCycles(t *testing.T) {
|
|
filename := "example"
|
|
g := ReadGraphFile(filename)
|
|
g.SaveAsMermaid("example-before-removing.mmd")
|
|
t.Logf("initial graph is %+v", g)
|
|
edges := g.RemoveAllCycles()
|
|
t.Logf("removed edges %+v", edges)
|
|
t.Logf("after removal graph is %+v", g)
|
|
g.SaveAsMermaid("example-after-removing.mmd")
|
|
}
|