MP Sir Sem - II Assignment Power Point Presentation

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

I-GRAPH USING R

NAME :- Sumit Saha


ROLL N.O :- 723
DEPARTMENT :- Computer Science
(Honours)
I-GRAPH & N-COMPLEXITY GRAPH
INDEX :-

1. 7.

2. 8.
3.
9.

4.
10.

5.
11.

6.
1.WRITE A PROGRAM
TO PLOT AN EMPTY
GRAPH.
CODE:

>library(igraph)

>g=make (10, directed=FALSE)

>plot(g)
2. WRITE A
PROGRAM TO PLOT
A CYCLIC GRAPH.
CODE:

>library(igraph)

>g1=make_ring (10,
directed=TRUE)

>plot(g1)
3.WRITE A CODE TO
PLOT K-REGULAR
GRAPH
CODE:

>library(igraph)

>g2=sample_k_regular (4,8,
directed=TRUE, multiple =TRUE)

>plot(g2)
4.WRITE A CODE TO
PLOT A DIRECTED
FULL GRAPH.
CODE:

>library(igraph)

>g3=make_full_graph (5, directed =


TRUE, loops = FALSE)

>plot (g3, edge. colour=” Black”)


5.WRITE A PROGRAM TO
PLOT GRAPH FOR ADDING
EDGES OF BLACK COLOUR
CODE:

>library(igraph)

>g4=make_empty_graph (8,
directed = FALSE)

>g4= add_edges (g4, c


(1,4,2,8,7,6,3,5))

>plot (g4, edge. Colour= “Black”)


6.WRITE A R CODE TO PLOT 6
VERTICES OF ORANGE COLOUR
AND UNDIRECTED EDGES OF
BLACK COLOUR.
CODE:

>library(igraph)

>g5=make_empty_graph (6,
directed = “FALSE”)

>g5=add_edges (g5, c
(1,2,2,3,3,4,4,5,5,6,1,3))

>plot (g5, edge. colour=” Black”,


vertex. Colour=” Orange”)
7.WRITE A CODE TO
PLOT RANDOM GRAPH
CODE:
>library(igraph)

>g6=erdos.renyi. game (6,1)

>plot(g6)
8.WRITE A R CODE TO PLOT
GRAPH FROM ADJACENCY
MATRIX

> library(igraph)

>aj_mat=matrix(c(0,1,0,1,0,1,0,1,1,0,0,1,0,1,1,1
,1,1,0,1,0,0,1,1,0),nrow=5,ncol=5,dimnames=lis
t(c("1","2","3","4","5"),c("1","2","3","4","5")))

> A=graph_from_adjacency_matrix(aj_mat)

>plot(A,edge.color="green",vertex.frame.color=
"red",vertex.label.color="white")

 
9.

CODE :- OUTPUT :-
> Fn = function(n){
+ for(i in 1:n) print(i)}
> x=NULL
> y=NULL
> c=1
> for(i in seq(1,100000,10000)){
+ a = Sys.time()
+ Fn(i)
+ b = Sys.time()
+ x[c] = i
+ y[c] = (b-a)
+ c=c+1}
+[1] 90000
[1] 90001
> plot(x,y)

BACK
Problem :- Write a program of n²-complexity and
10.
plot it’s graph.
CODE :- OUTPUT :-
> Fn = function(n){
+ for(i in 1:n){
+ for(j in 1:n){
+ print(i*j)}}}
> x=NULL
> y=NULL
> c=1
> for(i in seq(1,1000,100)){
+ a = Sys.time()
+ Fn(i)
+ b = Sys.time()
+ x[c] = i
+ y[c] = (b-a)
+ c=c+1}
[1] 809999
[1] 810900
[1] 811801
> plot(x,y)

BACK
11. Problem :- Write a program of n³-complexity and
plot it’s graph.
CODE :- OUTPUT :-
> Fn = function(n){
+ for(i in 1:n){
+ for(j in 1:n){
+ for(k in 1:n){
+ print(i*j*k)}}}}
> x=NULL
> y=NULL
> c=1
> for(i in seq(1,100,10)){
+ a = Sys.time()
+ Fn(i)
+ b = Sys.time()
+ x[c] = i
+ y[c] = (b-a)
+ c=c+1}

[1] 745290
[1] 753571
> plot(x,y)

BACK

You might also like