Created
November 5, 2015 23:35
-
-
Save jeanpat/c94965ceb6fd82a4d46d to your computer and use it in GitHub Desktop.
Making a weighted graph with graph-tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_toy_graph(): | |
T = gt.Graph(directed = False) | |
edge_weights = T.new_edge_property('double') | |
T.properties[("e","weight")] = edge_weights | |
T.add_vertex(n=4) | |
e_1 = T.add_edge(0,1) | |
e_2 = T.add_edge(1,2) | |
e_3 = T.add_edge(0,0) | |
e_4 = T.add_edge(1,3) | |
edge_weights[e_1]= 8 | |
edge_weights[e_2]= 15 | |
edge_weights[e_3]= 7 | |
edge_weights[e_4]= 20 | |
return T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment