Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:38:06+00:00 2026-06-02T17:38:06+00:00

Lets say i have generated some random alphabets and random numbers A 1 Z

  • 0

Lets say i have generated some random alphabets and random numbers

A 1
Z 2
C 3
L 2
E 4

and similarly another set

1 K
4 I
2 P
5 R
6 S
7 U

Now we can find 2 is linked to Z and L in the first case and similarly 2 is linked to P in the second set
from this we can say Z and L are connected to P
so intially i have generated the first two steps. I am a little confused how to proceed with rest?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:38:08+00:00Added an answer on June 2, 2026 at 5:38 pm

    The Graph module can help. In fact, concepts from Graph Theory are the right way to think about these sorts of problems instead of thrashing around with hashes and arrays trying to re-solve already solved problems.

    #!/usr/bin/env perl
    
    use strict; use warnings;
    use Graph::Directed;
    use Set::CrossProduct;
    
    my $g = Graph::Directed->new;
    
    my %first = qw(A 1 Z 2 C 3 L 2 E 4);
    my %second = qw(1 K 4 I 2 P 5 R 6 S 7 U);
    
    for my $h (\ (%first, %second) ) {
        $g->add_edge($_, $h->{$_}) for keys %$h;
    }
    
    print "All weakly connected components\n";
    
    for my $wcc ( $g->weakly_connected_components ) {
        print "[@$wcc]\n";
    }
    
    my $it = Set::CrossProduct->new([ [keys %first], [values %second]]);
    
    print "Connectedness tests\n";
    
    while (my $case = $it->get) {
        my $is_connected = $g->same_weakly_connected_components(@$case);
        printf(
            "%s are %s in the same weakly connected component\n",
            "[@$case]", $is_connected ? '' : 'not'
        );
    }
    

    Output

    All weakly connected components

    [R 5]
    [E 4 I]
    [K 1 A]
    [2 Z L P]
    [S 6]
    [7 U]
    [C 3]

    Connectedness tests

    [Z S] are not in the same weakly connected component
    [Z I] are not in the same weakly connected component
    [Z K] are not in the same weakly connected component
    [Z U] are not in the same weakly connected component
    [Z P] are  in the same weakly connected component
    [Z R] are not in the same weakly connected component
    [A S] are not in the same weakly connected component
    [A I] are not in the same weakly connected component
    [A K] are  in the same weakly connected component
    [A U] are not in the same weakly connected component
    [A P] are not in the same weakly connected component
    [A R] are not in the same weakly connected component
    [C S] are not in the same weakly connected component
    [C I] are not in the same weakly connected component
    [C K] are not in the same weakly connected component
    [C U] are not in the same weakly connected component
    [C P] are not in the same weakly connected component
    [C R] are not in the same weakly connected component
    [E S] are not in the same weakly connected component
    [E I] are  in the same weakly connected component
    [E K] are not in the same weakly connected component
    [E U] are not in the same weakly connected component
    [E P] are not in the same weakly connected component
    [E R] are not in the same weakly connected component
    [L S] are not in the same weakly connected component
    [L I] are not in the same weakly connected component
    [L K] are not in the same weakly connected component
    [L U] are not in the same weakly connected component
    [L P] are  in the same weakly connected component
    [L R] are not in the same weakly connected component
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have a loop in Bash: for foo in `some-command` do do-something
Lets say I have model inheritance set up in the way defined below. class
Lets say I have some pdf files stored on my server and I only
Lets say I have a class that is supposed to generate some ID (for
Lets say we have some discrete distribution with finite number of possible results, is
Lets say you have an array of size n with randomly generated elements and
I have a fields_for tag, where I specify the prefix (lets say for some
Let's say I have a solution involving an iPhone app that generates some information
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have this code: <?php class hello { var $greeting = hello;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.