graphs and their representation as edge lists
I have to represent a graph. how can this be done using edge lists? what is its format开发者_开发百科 actually?
Assuming you are talking about adjacency lists . . .
If you have a simple triangle where vertices are labeled a
, b
, and c
, then you would use something like this:
a | b, c
b | a, c
c | a, b
Depending on the implementation language, you could use, for example, a Dictionary<string, List<string>>
where the key would be the vertex label and the value would be a list of adjacent vertices.
See Wikipedia as well.
精彩评论