-
Notifications
You must be signed in to change notification settings - Fork 3
/
cgraph1.go
149 lines (115 loc) · 2.63 KB
/
cgraph1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package main
import (
"fmt"
S "SST"
)
// ********************************************************************************
func main() {
var dbname string = "centrality1"
var service_url string = "http://localhost:8529"
var user string = "root"
var pwd string = "mark"
var g S.Analytics
g = S.OpenAnalytics(dbname, service_url, user, pwd)
nodes := []S.Node{
S.Node{
"node1",
"Satellite 1",
"nodes",
1.0,
},
S.Node{
"node2",
"Stellite 2",
"nodes",
1.0,
},
S.Node{
"node3",
"Satellite 3",
"nodes",
1.0,
},
S.Node{
"node4",
"Satellite 4",
"nodes",
1.0,
},
S.Node{
"node5",
"Satellite 5",
"nodes",
1.0,
},
}
links := []S.Link{
S.Link {
From: "Nodes/node1",
To: "Nodes/node2",
SId: "CONNECTED",
Weight: 1, // Initialize all the same, positive
},
S.Link {
From: "Nodes/node2",
To: "Nodes/node3",
SId: "CONNECTED",
Weight: 1, // Initialize all the same, positive
},
S.Link {
From: "Nodes/node3",
To: "Nodes/node4",
SId: "CONNECTED",
Weight: 1, // Initialize all the same, positive
},
S.Link {
From: "Nodes/node4",
To: "Nodes/node1",
SId: "CONNECTED",
Weight: 1, // Initialize all the same, positive
},
S.Link {
From: "Nodes/node1",
To: "Nodes/node5",
SId: "CONNECTED",
Weight: 1, // Initialize all the same, positive
},
S.Link {
From: "Nodes/node2",
To: "Nodes/node5",
SId: "CONNECTED",
Weight: 1, // Initialize all the same, positive
},
S.Link {
From: "Nodes/node3",
To: "Nodes/node5",
SId: "CONNECTED",
Weight: 1, // Initialize all the same, positive
},
S.Link {
From: "Nodes/node4",
To: "Nodes/node5",
SId: "CONNECTED",
Weight: 1, // Initialize all the same, positive
},
}
// Convergent additions
fmt.Println("========== NEW IDEMP FNs ==============")
for node := range nodes {
S.AddNode(g,nodes[node])
}
for link := range links {
S.AddLink(g,links[link])
}
fmt.Println("========== SHOW NODES ==============")
S.PrintNodes(g, "Nodes")
fmt.Println("========== SHOW ADJ[node,node] ==============")
adjacency_matrix_keys := S.GetAdjacencyMatrixByKey(g,"CONNECTED",false)
fmt.Println(adjacency_matrix_keys)
fmt.Println("========== SHOW ADJ[i,j] ==============")
adjacency_matrix,dim,keys := S.GetAdjacencyMatrixByInt(g,"CONNECTED",false)
S.PrintMatrix(adjacency_matrix,dim,keys)
fmt.Println("========== SHOW principal ev[i] ==============")
ev := S.GetPrincipalEigenvector(adjacency_matrix,dim)
S.PrintVector(ev,dim,keys)
}