/graph tool test.py (b09bec79c503afa1126d86335d1372443e207773) (2132 bytes) (mode 100644) (type blob)
import graph_tool.all as gt
import networkx as nx
import matplotlib as mp
import matplotlib.pyplot as plt
g = nx.Graph()
g.add_edge(1,2)
g.add_edge(2,3)
g.add_edge(1,8)
print(g.nodes())
print(g.edges())
adj = nx.adjacency_matrix(g)
print(adj)
test = gt.Graph(directed=False)
test_name = test.new_vertex_property("string")
c1=test.add_vertex()
test_name[test.vertex(c1)] = "A"
c2=test.add_vertex()
test_name[test.vertex(c2)] = "B"
c=test.add_vertex()
test_name[test.vertex(c)] = "C"
test.add_edge(c1, c2)
gt.graph_draw(test)
found = gt.find_vertex(test,test_name,"C")
print(found)
if found <> []:
print("Index of B is")
print(found[0])
if (int(found[0])==1):
print("True")
else :
print("False")
#print('Index of B is',vertex.pop(0))
for v in test.vertices():
print v
print test.vertex(v)
print test_name[v]
# print(vp[test.vertex(v)])
def convert_graph(g):
#converts a networkX graph to graph_tool
#important : NetworkX node indexes start with 1, whereas Graph tool node indexes start with 0
j = gt.Graph(directed=False)
j.vertex_index
j.add_vertex(len(adj))
num_vertices = adj.shape[0]
print (num_vertices)
for i in range(num_vertices - 1):
for l in range(i + 1, num_vertices):
if adj[i,l] != 0:
j.add_edge(i, l)
return j
j = convert_graph(g)
for v in j.vertices():
print(v)
for e in j.edges():
print(e)
bg = nx.betweenness_centrality(g)
vp,ep = gt.betweenness(j)
print(bg)
#for u in range(1,len(bg)+1):
# print u
# print(bg[u])
for v in j.vertices():
print v
print(vp[j.vertex(v)])
#nx.draw(g)
#plt.draw()
#plt.show()
#gt.graph_draw(j)
#g = gt.collection.data["polblogs"]
#v1 = g.add_vertex()
#v2 = g.add_vertex()
#v3 = g.add_vertex()
#e = g.add_edge(v2, v1)
#f = g.add_edge(v3, v1)
#print(v1.out_degree())
#vp,ep = gt.betweenness(g)
#print(vp[g.vertex(1)])
#print(vp[g.vertex(2)])
#print(vp)
#print(type(vp))
#gt.graph_draw(g)
#print(vp[1],ep[1])
#gt.graph_draw(g.vp)
#gt.graph_draw(g, vertex_text=g.vertex_index, vertex_font_size=18,output_size=(200, 200), output="two-nodes.png")
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
6 |
0d20b6487c61e7d1bde93acf4a14b7a89083a16d |
.gitignore |
100644 |
blob |
103 |
924a1df9f7338af770d3cf3d4b0ce2673f10d1b0 |
README.md |
100644 |
blob |
0 |
e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |
__init__.py |
100644 |
blob |
1256 |
489636a0073e3dfe2bfd04ee893d609d304a8490 |
advancedscores.py |
100644 |
blob |
4854 |
b160ebc40fe35a499a9335db937985b806035b46 |
config.py |
040000 |
tree |
- |
1eae5e19b1eff05e464e361e3f50f3df23f1b754 |
data |
100644 |
blob |
4728 |
68b7ae967b6cb349e54a32d6d00528321f1825b3 |
file_importer.py |
100644 |
blob |
2132 |
b09bec79c503afa1126d86335d1372443e207773 |
graph tool test.py |
100644 |
blob |
716 |
359eb7179fa58d67044228556f7d9c38b5caec85 |
indexing.py |
100644 |
blob |
33232205 |
7ca601d1ca32abf3244359ce3ad85ea6a1b60010 |
log |
100644 |
blob |
6238 |
ae4072595be1e113bc28964ec19c6758b1b3ce20 |
metric_calculator.py |
100644 |
blob |
8308 |
6673fc89a71f9a87f57997fbd96c7ed3c36fb7ff |
metrics.py |
100644 |
blob |
1665 |
a959a8cc528f486a80a84e2ab233457870d255a1 |
normalizations.py |
100644 |
blob |
1565 |
32abe33200f0e8dd3bf4973e5956c7ab8545ca4b |
pearson.py |
100644 |
blob |
1696 |
26df05e3ec9f549013f400a6f5f5df7fdb617c2e |
start.py |
100644 |
blob |
2144 |
fb03eaa1cd8eb0d6c17b2019fe4c877a32bb7059 |
statistics.py |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/coria/coria-backend
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/coria/coria-backend
Clone this repository using git:
git clone git://git.rocketgit.com/user/coria/coria-backend
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main