0

If you are given a list containing information (i.e. each entry is a pair: (pair of nodes and an edge labeling)). How would go about constructing a undirected graph from the list and is it possible to achieve an O(m + n) running time, respective to the edges and vertices?

I guess the real question is what data structure would be most efficient, but is it still possible to achieve the desired linear running time starting from a list.

(Note: I'm not experienced at all with coding graphs/trees)

  • 1
    Your given list is already representing a graph. So, one could argue that there is nothing to do. A meaningful answer to your question can only be given when desired data structure is given. Usually, a data structure is chosen to perform well on needed operations (where importing is only one of many). So, you need to clarify what you want to do with your graph (or graphs). – Hinni Oct 09 '18 at 19:54
  • 2
    What do you mean by "edge labeling" ? Give an example of what a pair looks like. – SomeDude Oct 09 '18 at 23:05
  • Is your question "can we go from an edge list representation to an adjacency list representation in O(m + n) time" (where m is the number of edges and n the number of vertices)? – slider Oct 10 '18 at 03:01

0 Answers0