Am 04.03.20 um 15:26 schrieb sam:
Simple example using add_edge_list()
edges = [["A", "B", 10], ["A", "C", 10], ["B", "C", 10], ["C", "D", 1], ["B", "F", 1], ["A", "E", 1], ["D", "E", 10], ["D", "F", 10], ["E", "F", 10]]
g = Graph() eweight = g.new_edge_property("int") eprops = [eweight] g.add_edge_list(edges, eprops=eprops, hashed=True)
How do I recover the vertex names ("A", "B", "C", etc), so that after I fit an SBM I can collect membership of vertices?
Read the manual! The docstring of g.add_edge_list() explains exactly this, i.e. a property map is returned which contains the names.
Now, if I had loaded the same data set from a .csv using load_graph_from_csv() and run this:
g = load_graph_from_csv('edges.csv', hashed = True)
Then the following keep track of both edge weights and vertex names:
weights = g.edge_properties['c1'] vnames = g.vertex_properties
The above is obviously not what you intended, as vnames points to the whole property dictionary, not any particular property map.
However, if I fit an SBM to g using edge weights using this method, I get an error message:
AttributeError: 'str' object has no attribute 'key_type'
Since you have not specified what you have actually done by showing us the code, it's difficult to say what the problem is. Most likely, the edge property map passed had the incorrect type.
If you want us to help you, please remember to always provide a minimal and self-contained example that shows the problem. Giving error messages without the context tells us almost nothing.
Best, Tiago