IdentifyUpstreamOriginNodes
Id 1.3.6.1.4.1.33097.7.0.3.60001
Given a Digraph#1.3.6.1.4.1.33097.1.0.14 G=(V, E) with V Vertices(aka Nodes#1.3.6.1.4.1.33097.1.0.12.0) and E Edges#1.3.6.1.4.1.33097.1.0.12.1. Identify the number of UpstreamOriginNodes#1.3.6.1.4.1.33097.1.0.13.1.
The data will be provided in pairs of letters, each letter representing a NodeId#1.3.6.1.4.1.33097.1.0.12.0.0. In addition, an AdjacencyMap class will be provided as follows.
Code Listing
Performance
Time Cost
O(v log log v)
Space Cost
O(v)
Examples
Example A / #001
Input
a → d
e → f
d → f
Output
2
Example B / #002
Input
a → d
d → f
d → h
Output
1