IdentifyNodeNetworks

1.3.6.1.4.1.33097.7.0.3.60002

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 NodeNetworks#1.3.6.1.4.1.33097.1.0.12.

Pre-Requisite Problems

We suggest you solve this problem first; IdentifyUpstreamOriginNodes#1.3.6.1.4.1.33097.7.0.3.60001

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

1

Example B / #002

Input

a → d
c → f
d → z
Output

3