Skip to main content
Fix title to match challenge description
Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135

Determine number of unconnectedconnected components

Tweeted twitter.com/#!/StackCodeGolf/status/256409291920142336
deleted 5 characters in body
Source Link
arshajii
  • 2.2k
  • 12
  • 21

You are given a graph represented through an adjacency list. For example, the input

1-2 2-3 3-4 4-1

would correspond to the graph with nodes 1, 2, 3 and 4, where 1 is connected to 2, 2 is connected to 3, 3 is connected to 4, and 4 is connected to 1 (forming a square).

The task is to determine the number of of unconnectedconnected components of the graph represented by an inputted adjacency list. An "unconnectedA "connected component" is a set of nodes from which there is no path to any other node that is not in the set.

Example:

Intput: 1-2 2-3 4-5
Output: 2


Language of your choice - shortest code possible.

You are given a graph represented through an adjacency list. For example, the input

1-2 2-3 3-4 4-1

would correspond to the graph with nodes 1, 2, 3 and 4, where 1 is connected to 2, 2 is connected to 3, 3 is connected to 4, and 4 is connected to 1 (forming a square).

The task is to determine the number of of unconnected components of the graph represented by an inputted adjacency list. An "unconnected component" is a set of nodes from which there is no path to any other node that is not in the set.

Example:

Intput: 1-2 2-3 4-5
Output: 2


Language of your choice - shortest code possible.

You are given a graph represented through an adjacency list. For example, the input

1-2 2-3 3-4 4-1

would correspond to the graph with nodes 1, 2, 3 and 4, where 1 is connected to 2, 2 is connected to 3, 3 is connected to 4, and 4 is connected to 1 (forming a square).

The task is to determine the number of of connected components of the graph represented by an inputted adjacency list. A "connected component" is a set of nodes from which there is no path to any other node that is not in the set.

Example:

Intput: 1-2 2-3 4-5
Output: 2


Language of your choice - shortest code possible.

added 100 characters in body
Source Link
arshajii
  • 2.2k
  • 12
  • 21

You are given a graph represented through an adjacency list. For example, the input

1-2 2-3 3-4 4-1

would correspond to the graph with nodes 1, 2, 3 and 4, where 1 is connected to 2, 2 is connected to 3, 3 is connected to 4, and 4 is connected to 1 (forming a square).

The task is to determine the number of of unconnected components of the graph represented by an inputted adjacency list. An "unconnected component" is a set of nodes from which there is no path to any other node that is not in the set. So, for instance, a lone node with no connections would be considered an unconnected component.

Example:

Intput: 1-2 2-3 4-5
Output: 2


Language of your choice - shortest code possible.

You are given a graph represented through an adjacency list. For example, the input

1-2 2-3 3-4 4-1

would correspond to the graph with nodes 1, 2, 3 and 4, where 1 is connected to 2, 2 is connected to 3, 3 is connected to 4, and 4 is connected to 1 (forming a square).

The task is to determine the number of of unconnected components of the graph represented by an inputted adjacency list. An "unconnected component" is a set of nodes from which there is no path to any other node that is not in the set. So, for instance, a lone node with no connections would be considered an unconnected component.

Language of your choice - shortest code possible.

You are given a graph represented through an adjacency list. For example, the input

1-2 2-3 3-4 4-1

would correspond to the graph with nodes 1, 2, 3 and 4, where 1 is connected to 2, 2 is connected to 3, 3 is connected to 4, and 4 is connected to 1 (forming a square).

The task is to determine the number of of unconnected components of the graph represented by an inputted adjacency list. An "unconnected component" is a set of nodes from which there is no path to any other node that is not in the set.

Example:

Intput: 1-2 2-3 4-5
Output: 2


Language of your choice - shortest code possible.

Source Link
arshajii
  • 2.2k
  • 12
  • 21
Loading