Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuho committed Mar 28, 2016
1 parent c41a2e2 commit d460590
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (e EdgeSlice) Less(i, j int) bool { return e[i].Weight() < e[j].Weight() }
func (e EdgeSlice) Swap(i, j int) { e[i], e[j] = e[j], e[i] }

// Graph describes the methods of graph operations.
// It assumes that the identifier of a Vertex is string and unique.
// It assumes that the identifier of a Node is unique.
// And weight values is float64.
type Graph interface {
// Init initializes a Graph.
Expand Down
6 changes: 3 additions & 3 deletions graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func TestNewGraphFromJSON_graph(t *testing.T) {
if err != nil || !ok {
t.Fatalf("nil graph %v", err)
}
if g.GetNodeCount() != tg.TotalVertexCount {
t.Fatalf("%s | Expected %d but %d", tg.Name, tg.TotalVertexCount, g.GetNodeCount())
if g.GetNodeCount() != tg.TotalNodeCount {
t.Fatalf("%s | Expected %d but %d", tg.Name, tg.TotalNodeCount, g.GetNodeCount())
}
for _, elem := range tg.EdgeToWeight {
weight1, err := g.GetWeight(StringID(elem.Nodes[0]), StringID(elem.Nodes[1]))
Expand All @@ -76,7 +76,7 @@ func TestGraph_GetVertices(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if g.GetNodeCount() != tg.TotalVertexCount {
if g.GetNodeCount() != tg.TotalNodeCount {
t.Fatalf("wrong number of vertices: %s", g)
}
}
Expand Down
2 changes: 1 addition & 1 deletion minimum_spanning_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Kruskal(g Graph) (map[Edge]struct{}, error) {
// A = ∅
A := make(map[Edge]struct{})

// disjointSet maps a member Vertex to a represent.
// disjointSet maps a member Node to a represent.
// (https://en.wikipedia.org/wiki/Disjoint-set_data_structure)
forests := NewForests()

Expand Down
146 changes: 73 additions & 73 deletions testgraph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package testgraph

// Graph contains test data.
type Graph struct {
Name string
TotalVertexCount int
TotalEdgeCount int
IsDAG bool
EdgeToWeight []EdgeToWeight
Name string
TotalNodeCount int
TotalEdgeCount int
IsDAG bool
EdgeToWeight []EdgeToWeight
}

// EdgeToWeight maps Nodes to their weight between.
Expand Down Expand Up @@ -38,10 +38,10 @@ var GraphSlice = []Graph{

// Graph00 represents graph_00.
var Graph00 = Graph{
Name: "graph_00",
TotalVertexCount: 8,
TotalEdgeCount: 30,
IsDAG: false,
Name: "graph_00",
TotalNodeCount: 8,
TotalEdgeCount: 30,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"S", "A"}, 100.0},
EdgeToWeight{[]string{"S", "B"}, 14.0},
Expand Down Expand Up @@ -85,10 +85,10 @@ var Graph00 = Graph{

// Graph01 represents graph_01.
var Graph01 = Graph{
Name: "graph_01",
TotalVertexCount: 8,
TotalEdgeCount: 24,
IsDAG: false,
Name: "graph_01",
TotalNodeCount: 8,
TotalEdgeCount: 24,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"S", "A"}, 100.0},
EdgeToWeight{[]string{"S", "B"}, 14.0},
Expand Down Expand Up @@ -125,10 +125,10 @@ var Graph01 = Graph{

// Graph02 represents graph_02.
var Graph02 = Graph{
Name: "graph_02",
TotalVertexCount: 8,
TotalEdgeCount: 24,
IsDAG: false,
Name: "graph_02",
TotalNodeCount: 8,
TotalEdgeCount: 24,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"S", "A"}, 100.0},
EdgeToWeight{[]string{"S", "B"}, 20.0},
Expand Down Expand Up @@ -165,10 +165,10 @@ var Graph02 = Graph{

// Graph03 represents graph_03.
var Graph03 = Graph{
Name: "graph_03",
TotalVertexCount: 8,
TotalEdgeCount: 28,
IsDAG: false,
Name: "graph_03",
TotalNodeCount: 8,
TotalEdgeCount: 28,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"S", "B"}, 14.0},

Expand Down Expand Up @@ -210,10 +210,10 @@ var Graph03 = Graph{

// Graph04 represents graph_04.
var Graph04 = Graph{
Name: "graph_04",
TotalVertexCount: 6,
TotalEdgeCount: 20,
IsDAG: false,
Name: "graph_04",
TotalNodeCount: 6,
TotalEdgeCount: 20,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "B"}, 7.0},
EdgeToWeight{[]string{"A", "C"}, 9.0},
Expand Down Expand Up @@ -245,10 +245,10 @@ var Graph04 = Graph{

// Graph05 represents graph_05.
var Graph05 = Graph{
Name: "graph_05",
TotalVertexCount: 6,
TotalEdgeCount: 6,
IsDAG: true,
Name: "graph_05",
TotalNodeCount: 6,
TotalEdgeCount: 6,
IsDAG: true,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "F"}, 1.0},

Expand All @@ -264,10 +264,10 @@ var Graph05 = Graph{

// Graph06 represents graph_06.
var Graph06 = Graph{
Name: "graph_06",
TotalVertexCount: 8,
TotalEdgeCount: 9,
IsDAG: true,
Name: "graph_06",
TotalNodeCount: 8,
TotalEdgeCount: 9,
IsDAG: true,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "E"}, 1.0},
EdgeToWeight{[]string{"A", "H"}, 1.0},
Expand All @@ -287,10 +287,10 @@ var Graph06 = Graph{

// Graph07 represents graph_07.
var Graph07 = Graph{
Name: "graph_07",
TotalVertexCount: 6,
TotalEdgeCount: 8,
IsDAG: false,
Name: "graph_07",
TotalNodeCount: 6,
TotalEdgeCount: 8,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "E"}, 1.0},
EdgeToWeight{[]string{"A", "F"}, 1.0},
Expand All @@ -308,10 +308,10 @@ var Graph07 = Graph{

// Graph08 represents graph_08.
var Graph08 = Graph{
Name: "graph_08",
TotalVertexCount: 8,
TotalEdgeCount: 15,
IsDAG: false,
Name: "graph_08",
TotalNodeCount: 8,
TotalEdgeCount: 15,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "B"}, 1.0},
EdgeToWeight{[]string{"A", "E"}, 1.0},
Expand Down Expand Up @@ -340,10 +340,10 @@ var Graph08 = Graph{

// Graph09 represents graph_09.
var Graph09 = Graph{
Name: "graph_09",
TotalVertexCount: 6,
TotalEdgeCount: 12,
IsDAG: false,
Name: "graph_09",
TotalNodeCount: 6,
TotalEdgeCount: 12,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "C"}, 9.0},
EdgeToWeight{[]string{"A", "F"}, 20.0},
Expand All @@ -367,10 +367,10 @@ var Graph09 = Graph{

// Graph10 represents graph_10.
var Graph10 = Graph{
Name: "graph_10",
TotalVertexCount: 8,
TotalEdgeCount: 25,
IsDAG: false,
Name: "graph_10",
TotalNodeCount: 8,
TotalEdgeCount: 25,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"S", "A"}, 11.0},
EdgeToWeight{[]string{"S", "B"}, 17.0},
Expand Down Expand Up @@ -409,10 +409,10 @@ var Graph10 = Graph{

// Graph11 represents graph_11.
var Graph11 = Graph{
Name: "graph_11",
TotalVertexCount: 5,
TotalEdgeCount: 10,
IsDAG: false,
Name: "graph_11",
TotalNodeCount: 5,
TotalEdgeCount: 10,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"S", "A"}, 7.0},
EdgeToWeight{[]string{"S", "B"}, 6.0},
Expand All @@ -433,10 +433,10 @@ var Graph11 = Graph{

// Graph12 represents graph_12.
var Graph12 = Graph{
Name: "graph_12",
TotalVertexCount: 5,
TotalEdgeCount: 10,
IsDAG: false,
Name: "graph_12",
TotalNodeCount: 5,
TotalEdgeCount: 10,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"S", "A"}, 7.0},
EdgeToWeight{[]string{"S", "B"}, 6.0},
Expand All @@ -457,10 +457,10 @@ var Graph12 = Graph{

// Graph13 represents graph_13.
var Graph13 = Graph{
Name: "graph_13",
TotalVertexCount: 9,
TotalEdgeCount: 28,
IsDAG: false,
Name: "graph_13",
TotalNodeCount: 9,
TotalEdgeCount: 28,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "B"}, 4.0},
EdgeToWeight{[]string{"A", "H"}, 8.0},
Expand Down Expand Up @@ -503,10 +503,10 @@ var Graph13 = Graph{

// Graph14 represents graph_14.
var Graph14 = Graph{
Name: "graph_14",
TotalVertexCount: 8,
TotalEdgeCount: 14,
IsDAG: false,
Name: "graph_14",
TotalNodeCount: 8,
TotalEdgeCount: 14,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "B"}, 1.0},

Expand Down Expand Up @@ -534,10 +534,10 @@ var Graph14 = Graph{

// Graph15 represents graph_15.
var Graph15 = Graph{
Name: "graph_15",
TotalVertexCount: 10,
TotalEdgeCount: 17,
IsDAG: false,
Name: "graph_15",
TotalNodeCount: 10,
TotalEdgeCount: 17,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"A", "B"}, 1.0},
EdgeToWeight{[]string{"A", "F"}, 1.0},
Expand Down Expand Up @@ -570,10 +570,10 @@ var Graph15 = Graph{

// Graph16 represents graph_16.
var Graph16 = Graph{
Name: "graph_16",
TotalVertexCount: 8,
TotalEdgeCount: 15,
IsDAG: false,
Name: "graph_16",
TotalNodeCount: 8,
TotalEdgeCount: 15,
IsDAG: false,
EdgeToWeight: []EdgeToWeight{
EdgeToWeight{[]string{"S", "A"}, 10.0},
EdgeToWeight{[]string{"S", "B"}, 5.0},
Expand Down

0 comments on commit d460590

Please sign in to comment.