Is the graph representation for directed graph?

  • 10

    Well, I have some doubt about the graph representation in this problem, though it might not affect the solution to this problem. In this problem, we are asked to clone a undirected graph, which means for the pair of connected nodes, each one should be presented in the other's neighbors list.

    • For example: if there are two nodes 0 and 1 in a graph, and they are
      connected to each other, then the graph representation should be
    • So the test case in this problem, the graph
      {0,1,2#1,2#2,2} should be regarded as a directed graph.

    As said before, the solution might not be affected no matter what the representation is, but I don't want to be confused by the understanding of graph representation. So tell me if my understanding is wrong. Thanks!

  • 3

    You are right. The representation is for directed graph. Cloning directed or undirected graph can both be done in O(node*edge) time but the implementation differ a little bit.

  • 1

    this should be corrected. It is confusing people.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.