All problems
Dual Graph Face Count
Problem
Compute the number of faces of a connected plane graph from its edge count and vertex count.
Euler's formula V - E + F = 2 gives F = E - V + 2, where the outer face is included. n is the number of vertices and edges is the edge list of the embedded connected planar graph. Return F as an integer.
Hint
Every face of the plane graph becomes a vertex of the dual graph.
Test cases
case 1
in: [3,[[0,1],[1,2],[2,0]]]
expected: 2
case 2
in: [4,[[0,1],[1,2],[2,3],[3,0]]]
expected: 2
case 3
in: [4,[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]]
expected: 4
case 4
in: [5,[[0,1],[1,2],[2,3],[3,4],[4,0]]]
expected: 2
Starter codePython
def dual_graph_face_count(n, edges):
# Your code here
pass4 test cases · run your code against them in the editor