Professional Documents
Culture Documents
MP Sir Sem - II Assignment Power Point Presentation
MP Sir Sem - II Assignment Power Point Presentation
MP Sir Sem - II Assignment Power Point Presentation
1. 7.
2. 8.
3.
9.
4.
10.
5.
11.
6.
1.WRITE A PROGRAM
TO PLOT AN EMPTY
GRAPH.
CODE:
>library(igraph)
>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)
>library(igraph)
>g4=make_empty_graph (8,
directed = FALSE)
>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(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