Computer scienceAlgorithms and Data StructuresData structuresGraphsGraphs: basics

Nodes, cycles and paths

Hubs

Report a typo

Imagine there are 10 sites with the identifiers A, B, C, D, E, F, G, H, I, and J. There is a link from

  • I to J;
  • B to C;
  • E to F;
  • C to G;
  • G to H;
  • H to G;
  • H to I;
  • C to A;
  • A to B;
  • D to E;
  • F to D;
  • F to J;
  • J to I;
  • B to D.

To better understand this scenario, please create a visual representation of the network by drawing it on paper. Now, let's name a group of sites a hub if each site of this group is reachable via links from any other site of this group. To make the definition clear, let's consider the following example:

Directed graph

Here, the sites AA, BB, and DD form a hub, since each site from this group is reachable to any other via links. Despite the fact that there is a link from BB to CC, the site CC is not included to the hub because there is no link from CC to BB and hence neither of AA, BB, or DD is reachable from CC.

Your task here is to find all hubs for the 10 mentioned sites and enter them in the field below. The expected output format is the following:

A B
C D
F G H

Here each line corresponds to a hub, and sites' identifiers are separated by spaces.

Tip: Please be mindful of the case sensitivity when entering site identifiers. All site identifiers are provided in UPPERCASE LETTERS, and using lowercase letters will represent different nodes. Site identifiers within a hub can be entered in any order. Additionally, ensure proper spacing and follow the specified output format.
Enter a short text
___

Create a free account to access the full topic