# Category: Graphs

## Graphs

Graphs Representation Adjacency Matrix Adjacency Lists Traversal schemes DFS (Depth First Search) Breadth First Search (BFS) Minimal Spanning Kruskal Prim Graph:  A graph consists of a set of nodes (vertices) and a set of arcs (or edges). The set of nodes {1,2,3,4} The set of arcs or edges {(1,2), (1,3), (1,4), (2,4), (2,3), (3,4)} Thus […]

## Implementation of Adjacency List Representation for Graphs

Graphs Implementation of Adjacency List Representation for Graphs /*Implementation of Adjacency List Representation for graphs*/ #include <stdio.h> #include <conio.h> #include <string.h> #include <stdlib.h> #define MAX 4 struct edge; typedef struct node { int id; char city; struct edge *next; }VERTEX; typedef struct edge { int adj; int distance; struct edge *next; }EDGE; VERTEX *nodes[MAX]={NULL}; VERTEX […]

## Program to sketch a Graph using Adjacency matrix

Graphs Program to sketch a Graph using Adjacency matrix /*Program to sketch a graph using adjacency matrix*/ #include <stdio.h> #include <conio.h> #include <string.h> #define MAX 4 struct vertex {int num; }; struct edge {int adj; }; struct graph {struct vertex nodes[MAX]; struct edge edges[MAX][MAX]; }g; int return_subscript(int val) {int i; for(i=0;i<MAX;i++) {if(g.nodes[i].num==val) return i; } […]

## Program to implement Graphs using Adjacency Matrix

Graphs Program to implement Graphs using Adjacency Matrix /*Implementation of adjacency matrix*/ #include <stdio.h> #include <conio.h> #include <string.h> #define MAX 4 typedef struct node {int id; char city; }VERTEX; typedef struct edge {int adj; int distance; }EDGE; typedef struct graph {VERTEX v[MAX]; EDGE e[MAX][MAX]; }GRAPH; GRAPH g; int return_subscript(char s[]); void main() { int i,j; […]