Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how to write a python program to run this question. Girth of a digraph For a digraph G, the length of the shortest cycle is

image text in transcribedhow to write a python program to run this question.

Girth of a digraph For a digraph G, the length of the shortest cycle is called the directed girth of the graph If the digraph has no cycle then the girth is undefined, and we will say it has girth 0. Your task is to determine the directed girth of each input digraph Input Format Input for this problem consists of a sequence of one or more digraphs taken from the keyboard (System.in). Each graph is represented by an adjacency list. The first line is an integer n indicating the order of the graph. This is followed by n white space separated lists of adjacencies for nodes labeled 0 ton - 1. The input will be terminated by a line consisting of one zero (0). This line should not be processed. Two sample input digraphs are listed below. The test cases are digraphs of order at most 30. 4 1 3 2 3 0 3 1 2 0 OutputFormat Output will be just one integer per line sent to the console (e.g. System.out). For the above, input we would output the following two integers denoting the girth of the two graphs, using 0 to indicate the graph has no cycle. 3 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions