All problems
Scene Graph Count
Problem
Return [number of unique objects, number of unique relations] for a scene graph given as [subject, relation, object] triples.
Objects are the union of subjects and objects across all triples.
Hint
A node appearing as both subject and object is counted once.
Test cases
case 1
in: [[["cat","on","mat"],["cat","chases","mouse"]]]
expected: [3,2]
case 2
in: [[]]
expected: [0,0]
case 3
in: [[["a","r","a"]]]
expected: [1,1]
case 4
in: [[["a","r1","b"],["b","r2","c"]]]
expected: [3,2]
Starter codePython
def scene_graph_count(triples):
# Your code here
pass4 test cases · run your code against them in the editor