Queries to check if vertices X and Y

Queries to check if vertices X and Y

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive.

Given an undirected graph consisting of N vertices and M edges and queries Q[][] of the type {X, Y}, the task is to check if the vertices X and** Y** are in the same connected component of the Graph.

Examples:

Input:_ Q[][] = {{1, 5}, {3, 2}, {5, 2}} _

_Graph: _

1-3-4   2
  |
  5   

Output:_ Yes No No _

Explanation:

_From the given graph, it can be observed that the vertices {1, 5} are in the same connected component. _

But {3, 2} and {5, 2} are from different components.

Input:_ Q[][] = {{1, 9}, {2, 8}, {3, 5}, {7, 9}} _

_Graph: _

1-3-4  2-5-6  7-9
       |
       8   

Output:_ No Yes No Yes _

Explanation:

_From the given graph, it can be observed that the vertices {2, 8} and {7, 9} is from same connected component. _

_But {1, 9} and {3, 5} are from different components. _

data visualization

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Visual Analytics and Advanced Data Visualization

Visual Analytics and Advanced Data Visualization - How CanvasJS help enterprises in creating custom Interactive and Analytical Dashboards for advanced visual analytics for data visualization

Visualization Best Practices for Data Scientists

Visualization Best Practices for Data Scientists. Disclaimer: The ideas presented in this article are from the book: Story Telling With Data by Cole Nussbaumer Knaflic.

Applications Of Data Science On 3D Imagery Data

The agenda of the talk included an introduction to 3D data, its applications and case studies, 3D data alignment and more.

The Importance of Data Visualization

The Importance of Data Visualization - It is the process of converting raw data at hand into easy and understandable image-photo-graphics for fast, effective and accurate…

Data Quality Testing Skills Needed For Data Integration Projects

Data Quality Testing Skills Needed For Data Integration Projects. Data integration projects fail for many reasons. Risks can be mitigated when well-trained testers deliver support. Here are some recommended testing skills.