The Wayback Machine - https://web.archive.org/web/20241127030832/https://www.geeksforgeeks.org/graph-theory-practice-questions/
Open In App

Mathematics | Graph theory practice questions

Last Updated : 18 Sep, 2023
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Problem 1 – There are 25 telephones in Geeksland. Is it possible to connect them with wires so that each telephone is connected with exactly 7 others. 

Solution – Let us suppose that such an arrangement is possible. This can be viewed as a graph in which telephones are represented using vertices and wires using the edges. Now we have 25 vertices in this graph. The degree of each vertex in the graph is 7. From handshaking lemma, we know.

sum of degrees of all vertices = 2*(number of edges)
number of edges = (sum of degrees of all vertices) / 2

We need to understand that an edge connects two vertices. So the sum of degrees of all the vertices is equal to twice the number of edges. Therefore,

 25*7 = 2*(number of edges)
number of edges = 25*7 / 2 = 87.5

This is not an integer. As a result we can conclude that our supposition is wrong and such an arrangement is not possible.   

Problem 2 – The figure below shows an arrangement of knights on a 3*3 grid. 

 Figure – initial state Is it possible to reach the final state as shown below using valid knight’s moves ? 

 Figure – final state Solution – NO. You might think you need to be a good chess player in order to crack the above question. However the above question can be solved using graphs. But what kind of a graph should we draw? Let each of the 9 vertices be represented by a number as shown below. 

 Now we consider each square of the grid as a vertex in our graph. There exists a edge between two vertices in our graph if a valid knight’s move is possible between the corresponding squares in the graph. For example – If we consider square 1. The reachable squares with valid knight’s moves are 6 and 8. We can say that vertex 1 is connected to vertices 6 and 8 in our graph. Similarly we can draw the entire graph as shown below. Clearly vertex 5 can’t be reached from any of the squares. Hence none of the edges connect to vertex 5. 

 We use a hollow circle to depict a white knight in our graph and a filled circle to depict a black knight. Hence the initial state of the graph can be represented as : 

 Figure – initial state The final state is represented as : 

Figure – final state Note that in order to achieve the final state there needs to exist a path where two knights (a black knight and a white knight cross-over). We can only move the knights in a clockwise or counter-clockwise manner on the graph (If two vertices are connected on the graph: it means that a corresponding knight’s move exists on the grid). However the order in which knights appear on the graph cannot be changed. There is no possible way for a knight to cross over (Two knights cannot exist on one vertex) the other in order to achieve the final state. Hence, we can conclude that no matter what the final arrangement is not possible.  

 Problem 3: There are 9 line segments drawn in a plane. Is it possible that each line segment intersects exactly 3 others? 

Solution: This problem seems very difficult initially. We could think of solving it using graphs. But how do we do draw the graph. If we try to approach this problem by using line segments as edges of a graph,we seem to reach nowhere (This sounds confusing initially). Here we need to consider a graph where each line segment is represented as a vertex. Now two vertices of this graph are connected if the corresponding line segments intersect. Now this graph has 9 vertices. The degree of each vertex is 3. 

We know that for a graph 

Sum of degrees of all vertices = 2* Number of Edges in the graph 

Since the sum of degrees of vertices in the above problem is 9*3 = 27 i.e odd, such an arrangement is not possible. 


Previous Article
Next Article

Similar Reads

Mathematics | Graph Theory Basics - Set 1
A graph is a data structure that is defined by two components : A node or a vertex.An edge E or ordered pair is a connection between two nodes u,v that is identified by unique pair(u,v). The pair (u,v) is ordered because (u,v) is not same as (v,u) in case of directed graph.The edge may have a weight or is set to one in case of unweighted graph.Cons
4 min read
Mathematics | Graph Theory Basics - Set 2
Graph theory is a basic branch of discrete mathematics that mainly focuses on the relationship between objects. These objects are called vertices and these vertices are joined by edges. Graphs are common in computer science, network analysis, and many other everyday uses because they provide a good representation of connection, relationship, and pr
10 min read
Regular Graph in Graph Theory
Prerequisite: Graph Theory Basics – Set 1, Set 2 Regular Graph: A graph is called regular graph if degree of each vertex is equal. A graph is called K regular if degree of each vertex in the graph is K. Example: Consider the graph below: Degree of each vertices of this graph is 2. So, the graph is 2 Regular. Similarly, below graphs are 3 Regular an
2 min read
Euler Graph and Arbitrarily Traceable Graphs in Graph Theory
Prerequisites: Walks, trails, paths, cycles, and circuits in a graph If some closed walk in a graph contains all the vertices and edges of the graph, then the walk is called an Euler Line or Eulerian Trail and the graph is an Euler Graph. In this article, we will study the Euler graph and arbitrarily traceable graph. Consider an Euler Graph shown i
2 min read
Mathematics Practice Questions
Mathematics Practice Questions: This collection of advanced maths practice questions is designed to test and enhance the problem-solving skills of students. These questions cover a wide range of mathematical topics, including algebra, geometry, and arithmetic operations, tailored for students seeking to deepen their understanding of mathematical co
9 min read
Number Theory in Mathematics
Number theory is one of the many branches of mathematics used to explore the intricate patterns and properties inherent in integers and their relationships. It helps us study prime numbers and reveals various interesting patterns in them. In this article, we will discuss how number theory is used in other branches of mathematics, providing examples
4 min read
Number Theory in Discrete Mathematics
Discrete mathematics deals with counting individual items, such as whole numbers, rather than continuous quantities like real numbers. Number theory, a major component of discrete math, delves into the properties and behaviors of integers, especially natural numbers and occasionally all integers. Understanding number theory is crucial in comprehend
5 min read
Graph Transformations Practice Questions
Graph transformations are essential tools in mathematics that allow us to manipulate the appearance and position of graphs on a coordinate plane. These transformations include shifting, reflecting, stretching, and rotating graphs. Understanding these transformations is crucial for analyzing functions and interpreting data visually. In other words w
10 min read
Practice Problems on Game Theory
Game Theory is a topic in competitive programming that involves a certain type of problem, where there are some players who play a game based on given rules and the task is often to find the winner or the winning moves. Game Theory is often asked in short contests with a mixture of other topics like range querying or greedy or dynamic programming.
4 min read
Proof that Independent Set in Graph theory is NP Complete
Prerequisite: NP-Completeness, Independent set. An Independent Set S of graph G = (V, E) is a set of vertices such that no two vertices in S are adjacent to each other. It consists of non- adjacent vertices. Problem: Given a graph G(V, E) and an integer k, the problem is to determine if the graph contains an independent set of vertices of size >
5 min read
5 Color Theorem in Graph Theory
The graph is a data structure that is used extensively in real-life. Planar Graph: If a graph can be drawn on the plane without crossing, it is said to be planar. Coloring of a simple graph is the assignment of color to each vertex of the graph so that no two adjacent vertices are assigned the same color. Bi-Partite Graphs: A bipartite graph, also
4 min read
Clustering Coefficient in Graph Theory
In graph theory, a clustering coefficient is a measure of the degree to which nodes in a graph tend to cluster together. Evidence suggests that in most real-world networks, and in particular social networks, nodes tend to create tightly knit groups characterized by a relatively high density of ties; this likelihood tends to be greater than the aver
5 min read
Applications of Graph Theory
Applications of Graph Theory: In mathematics and computer science, a graph is a mathematical structure that consists of two main components: vertices (or nodes) and edges. The study of these graphs in various contexts is called graph theory. There are various applications of graph theory in real life such as in computer graphics and networks, biolo
9 min read
Fundamentals of Graph Theory
Graph theory is a branch of mathematics that studies the properties and applications of graphs. A graph is a collection of vertices (also called nodes) connected by edges (also called links). Graphs are used to model pairwise relations between objects, making them a powerful tool for representing and analyzing complex systems in various fields. In
10 min read
Matching (Graph Theory)
Matching (Graph Theory): In graph theory, matching is a fundamental concept used to describe a set of edges without common vertices. Matchings are used in various applications such as network design, job assignments, and scheduling. Understanding matchings is essential for solving problems involving optimal pairings and resource allocation. Table o
4 min read
Mathematics | Graph Isomorphisms and Connectivity
Graph theory is a fundamental area in mathematics and computer science, which studies the properties of graphs and their applications. Two essential concepts in graph theory are graph isomorphisms and connectivity. Graph isomorphisms help determine if two graphs are structurally identical, while connectivity measures the degree to which the vertice
3 min read
Theory of Computation - GATE CSE Previous Year Questions
Solving GATE Previous Year's Questions (PYQs) not only clears the concepts but also helps to gain flexibility, speed, accuracy, and understanding of the level of questions generally asked in the GATE exam, and that eventually helps you to gain good marks in the examination. Previous Year Questions help a candidate practice and revise for GATE, whic
5 min read
Set Theory Questions
Set Questions have been provided here to simplify the concept of sets and relations for the students of Class 11. These set questions have been designed according to the latest CBSE syllabus. From basic sets and relations to set functions and subsets, we've covered key areas to help you develop a good understanding of set theory. Set Theory Questio
9 min read
Discrete Mathematics - GATE CSE Previous Year Questions
Solving GATE Previous Year's Questions (PYQs) not only clears the concepts but also helps to gain flexibility, speed, accuracy, and understanding of the level of questions generally asked in the GATE exam, and that eventually helps you to gain good marks in the examination. Previous Year Questions help a candidate practice and revise for GATE, whic
4 min read
Engineering Mathematics - GATE CSE Previous Year Questions
Solving GATE Previous Year's Questions (PYQs) not only clears the concepts but also helps to gain flexibility, speed, accuracy, and understanding of the level of questions generally asked in the GATE exam, and that eventually helps you to gain good marks in the examination. Previous Year Questions help a candidate practice and revise for GATE, whic
4 min read
Detect cycle in the graph using degrees of nodes of graph
Given a graph, the task is to detect a cycle in the graph using degrees of the nodes in the graph and print all the nodes that are involved in any of the cycles. If there is no cycle in the graph then print -1. Examples: Input: Output: 0 1 2 Approach: Recursively remove all vertices of degree 1. This can be done efficiently by storing a map of vert
11 min read
Convert the undirected graph into directed graph such that there is no path of length greater than 1
Given an undirected graph with N vertices and M edges and no self loops or multiple edges. The task is to convert the given undirected graph into a directed graph such that there is no path of length greater than 1. If it is possible to make such a graph then print two space-separated integers u and v in M lines where u, v denotes source and destin
10 min read
Maximum number of edges that N-vertex graph can have such that graph is Triangle free | Mantel's Theorem
Given a number N which is the number of nodes in a graph, the task is to find the maximum number of edges that N-vertex graph can have such that graph is triangle-free (which means there should not be any three edges A, B, C in the graph such that A is connected to B, B is connected to C and C is connected to A). The graph cannot contain a self-loo
4 min read
Convert undirected connected graph to strongly connected directed graph
Given an undirected graph of N vertices and M edges, the task is to assign directions to the given M Edges such that the graph becomes Strongly Connected Components. If a graph cannot be converted into Strongly Connected Components then print "-1". Examples: Input: N = 5, Edges[][] = { { 0, 1 }, { 0, 2 }, { 1, 2 }, { 1, 4 }, { 2, 3 }, { 3, 4 } } Ou
14 min read
Connect a graph by M edges such that the graph does not contain any cycle and Bitwise AND of connected vertices is maximum
Given an array arr[] consisting of values of N vertices of an initially unconnected Graph and an integer M, the task is to connect some vertices of the graph with exactly M edges, forming only one connected component, such that no cycle can be formed and Bitwise AND of the connected vertices is maximum possible. Examples: Input: arr[] = {1, 2, 3, 4
9 min read
What is Directed Graph? | Directed Graph meaning
A directed graph is defined as a type of graph where the edges have a direction associated with them. Characteristics of Directed Graph Directed graphs have several characteristics that make them different from undirected graphs. Here are some key characteristics of directed graphs: Directed edges: In a directed graph, edges have a direction associ
3 min read
What is Undirected Graph? | Undirected Graph meaning
An undirected graph is a type of graph where the edges have no specified direction assigned to the them. Characteristics of an Undirected Graph:Edges in an undirected graph are bidirectional in nature.In an undirected graph, there is no concept of a "parent" or "child" vertex as there is no direction to the edges.An undirected graph may contain loo
2 min read
Graph implementation using STL for competitive programming | Set 2 (Weighted graph)
In Set 1, unweighted graph is discussed. In this post, weighted graph representation using STL is discussed. The implementation is for adjacency list representation of weighted graph. We use two STL containers to represent graph: vector : A sequence container. Here we use it to store adjacency lists of all vertices. We use vertex number as index in
7 min read
Bar Graph - Examples & How To Draw a Bar Graph
Bar Graph in Maths: A bar chart displays categorical data using rectangular bars whose heights or lengths correspond to the values they represent. These bars can be arranged vertically or horizontally. When plotted vertically, the bar chart is often referred to as a column chart. A bar graph is a visual representation of data using rectangular bars
14 min read
Chromatic Number of a Graph | Graph Colouring
Graph coloring is a fundamental concept in graph theory, and the chromatic number is a key parameter that quantifies the coloring properties of a graph. Let's go into the introductory aspects of the chromatic number. Graph coloring refers to the problem of coloring vertices of a graph in such a way that no two adjacent vertices have the same color.
15+ min read
three90RightbarBannerImg