## Coloring Graph Updated on 23-Aug-2019 06:52:35
Graph coloring is nothing but a simple way of labelling graph components such as vertices, edges, and regions under some constraints. In a graph, no two adjacent vertices, adjacent edges, or adjacent regions are colored with minimum number of colors. This number is called the chromatic number and the graph is called a properly colored graph.While graph coloring, the constraints that are set on the graph are colors, order of coloring, the way of assigning color, etc. A coloring is given to a vertex or a particular region. Thus, the vertices or regions having same colors form independent sets.Vertex ColoringVertex ... Read More

## MySQL statement to copy data from one table and insert into another table Updated on 23-Aug-2019 06:42:48
For this, you can use INSERT INTO….SELECT statement. Let us first create a table −mysql> create table DemoTabe1 (Marks int); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTabe1 values(68); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTabe1 values(89); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTabe1 values(99); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTabe1 values(39); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTabe1 values(49); Query OK, 1 row affected (0.12 sec)Display all records from the table ... Read More

## Circuit Rank Updated on 23-Aug-2019 06:41:24
Let 'G' be a connected graph with 'n' vertices and 'm' edges. A spanning tree 'T' of G contains (n-1) edges.Therefore, the number of edges you need to delete from 'G' in order to get a spanning tree = m-(n-1), which is called the circuit rank of G.This formula is true, because in a spanning tree you need to have 'n-1' edges. Out of 'm' edges, you need to keep 'n–1' edges in the graph.Hence, deleting 'n–1' edges from 'm' gives the edges to be removed from the graph in order to get a spanning tree, which should not form ... Read More

## Injective, Surjective and Bijective Functions Updated on 23-Aug-2019 06:40:53
Injective / One-to-one functionA function $f: A \rightarrow B$ is injective or one-to-one function if for every $b \in B$, there exists at most one $a \in A$ such that $f(s) = t$.This means a function f is injective if $a_1 e a_2$ implies $f(a1) e f(a2)$.Example$f: N \rightarrow N, f(x) = 5x$ is injective.$f: N \rightarrow N, f(x) = x^2$ is injective.$f: R\rightarrow R, f(x) = x^2$ is not injective as $(-x)^2 = x^2$Surjective / Onto functionA function $f: A \rightarrow B$ is surjective (onto) if the image of f equals its range. Equivalently, for every $b \in B$, ... Read More

## Divide numbers from two columns and display result in a new column with MySQL Updated on 23-Aug-2019 06:39:15
Let us first create a table −mysql> create table DemoTable719 (FirstNumber int, SecondNumber int); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable719 values(20, 10); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable719 values(500, 50); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable719 values(400, 20); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable719;This will produce the following output −+-------------+--------------+ | FirstNumber | SecondNumber | +-------------+--------------+ | 20          | ... Read More

## Centers of a tree Updated on 23-Aug-2019 06:34:41
The center of a tree is a vertex with minimal eccentricity. The eccentricity of a vertex X in a tree G is the maximum distance between the vertex X and any other vertex of the tree. The maximum eccentricity is the tree diameter. If a tree has only one center, it is called Central Tree and if a tree has only more than one centers, it is called Bi-central Tree. Every tree is either central or bi-central.Algorithm to find centers and bi-centers of a treeStep 1 − Remove all the vertices of degree 1 from the given tree and also ... Read More Updated on 23-Aug-2019 06:30:14
Graph traversal is the problem of visiting all the vertices of a graph in some systematic order. There are mainly two ways to traverse a graph.Breadth First SearchDepth First SearchBreadth First Search (BFS) starts at starting level-0 vertex X of the graph G. Then we visit all the vertices that are the neighbors of X. After visiting, we mark the vertices as "visited, " and place them into level-1. Then we start from the level-1 vertices and apply the same method on every level-1 vertex and so on. The BFS traversal terminates when every vertex of the graph has been ... Read More

## Fetch ordered records after a specific limit in MySQL Updated on 23-Aug-2019 06:29:34
For this, you can use a subquery. Let us first create a table −mysql> create table DemoTable618 (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100) ); Query OK, 0 rows affected (1.45 sec)Insert some records in the table using insert command −mysql> insert into DemoTable618(StudentFirstName) values('David'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable618(StudentFirstName) values('Chris'); Query OK, 1 row affected (0.44 sec) mysql> insert into DemoTable618(StudentFirstName) values('Robert'); Query OK, 1 row affected (0.54 sec) mysql> insert into DemoTable618(StudentFirstName) values('Sam'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable618(StudentFirstName) values('Mike'); Query OK, 1 ... Read More

## Bipartite Graphs Updated on 23-Aug-2019 06:27:37
Bipartite Graph - If the vertex-set of a graph G can be split into two disjoint sets, V1 and V2 , in such a way that each edge in the graph joins a vertex in V1 to a vertex in V2 , and there are no edges in G that connect two vertices in V1 or two vertices in V2 , then the graph G is called a bipartite graph.Complete Bipartite Graph - A complete bipartite graph is a bipartite graph in which each vertex in the first set is joined to every single vertex in the second set. The ... Read More

## Basic Concepts of Graphs Updated on 23-Aug-2019 06:25:16
A graph is a set of points, called nodes or vertices, which are interconnected by a set of lines called edges. The study of graphs, or graph theory is an important part of a number of disciplines in the fields of mathematics, engineering and computer science.Graph TheoryDefinition − A graph (denoted as G = (V, E)) consists of a non-empty set of vertices or nodes V and a set of edges E. A vertex a  represents an endpoint of an edge. An edge joins two vertices a, b  and is represented by set of vertices it connects.Example − Let us ... Read More