Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 44

A

Mini project report

On

Automation of trimet graph(TPO Topology)

Submitted by

Vishnu vardhan.k sai srinivas.k

Prudhvi sai sravani.u

Under the guidance

of

Shanmukh srinivas.A

BACHELOR OF TECHNOLOGY

IN

COMPUTER SCIENCE AND ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


GITAM
(Deemed to be University)
VISAKHAPATNAM
CERTIFICATE

Gitam deemed to be university

This is to certify that

Sai srinivas kammili [1215316923] Vishnu vardhan[1215316929]

prudhvi sai[1215316912] sravani.u [1215316964]

Have successfully completed the

Project work entitled

“Automation of trimet graph(TPO TOPOLOGY)“

For the partial fulfillment of requirements leading to the

Degree of Bachelor of Engineering in Computer science Engineering

Awarded by

Gitam deemed to be university

For the Academic year

2019-2020

A.SHANMUK SRINIVAS

(Guide )
ACKNOWLEDGEMENT

The final phase of our project work has finally been completed with satisfying results. The
successful completion of any software project would never be possible without the help and
cooperation of the people involved. Likewise, our project would never materialize without
the support and encouragement of many people around us.

We are very grateful to our respected project guide A.shanmukh srinivas(guide), for his
personal involvement and constructive suggestions throughout the project schedule. He took
deep interest in correcting the minor problems and guided us through our journey so far. Also
he has been a persistent source of inspiration for us.

We wish to express our thanks to our p.chandra sekhar , who continuously gave us advice
and useful hints that helped make our project a very special work.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

GITAM INSTITUTE OF TECHNOLOGY

GITAM

(Deemed to be University)

DECLARATION

We, hereby declare that the project report entitled “Automation of trimet graphs
optimization topology” is an original work done in the Department of Computer Science
and Engineering, GITAM Institute of Technology, GITAM (Deemed to be University)
submitted in partial fulfillment of the requirements for the award of the degree of B.Tech. in
Computer Science and Engineering. The work has not been submitted to any other college or

University for the award of any degree or diploma.

Date:

Registration No(s). Name(s)

1215316929 vishnu vardhan.k

1215316923 sai srinivas.k

1215316964 sravani.u

1215316912 prudhvi sai


Table of contents
1 Abstract
2 Introduction
3 Problem Defnition
4 Problem Diagrammatic Representation
5 Overview of Technologies
6 Coding and Testing
7 Conclusion
8 References
Abstract:

In practical there could be realistic situations to connect with each other in a


group for better communication system among all. To tackle these types of problems graph
theory has envisaged Complete Graph, K (1, n) Graph etc. A Graph has been introduced so
called TRIMET, which has been conceived from typical and optimized properties of Existing
Complete Graph. The main purpose of this TRIMET is to establish a better communication
system with fewer infrastructures when compared with Complete Graph. TRIMET monitors
all the vertices with the help of Dominant Vertex, which is having a communication path
from all the vertices of Graph, by making sectors, which establishes a communication path
among two or three vertices of Sector. Finally we analyze the normal graph trimet with
network scheme and standard properties like diameter,average path length etc
Introduction :

The whole project is to automate the concept of trimet graph . In practical there could be
realistic situations to connect with each other in a group for better communication system
among all. In practical there could be realistic situations to connect with each other in a group
for better communication system among all. To tackle these types of problems graph theory
has envisaged Complete Graph, K (1, n) Graph etc. A Graph has been introduced so called
TRIMET, which has been conceived from typical and optimized properties of Existing
Complete Graph. The main purpose of this TRIMET is to establish a better communication
system with fewer infrastructures when compared with Complete Graph. TRIMET monitors
all the vertices with the help of Dominant Vertex, which is having a communication path
from all the vertices of Graph, by making sectors, which establishes a communication path
among two or three vertices of Sector. Finally we analyze the normal graph trimet with
network scheme and standard properties like diameter,average path length etc

Problem definition:
The capability of a system, network, or process to handle a growing amount of
work, or its potential to be enlarged in order to accommodate that growth.It means in near
future the network devices increase exponentially . our project goal is used to develop a
model (trimet graph) which can handle large number of devices with less complexity

Problem Diagrammatic Representation:


graph theory

scalability
Machine learning gametheory

Artificial intelligence

Graph theory

scalability

Trimet graph

TGO TOPOLOGY
Technologies used:

Python: Python was designed for readability, and has some similarities to the English
language with influence from mathematics.

 Python uses new lines to complete a command, as opposed to other programming


languages which often use semicolons or parentheses.
 Python relies on indentation, using whitespace, to define scope; such as the scope of
loops, functions and classes. Other programming languages often use curly-brackets
for this purpose.
 Python can be used on a server to create web applications.
 Python can be used alongside software to create workflows.
 Python can connect to database systems. It can also read and modify files.
 Python can be used to handle big data and perform complex mathematics.
 Python can be used for rapid prototyping, or for production-ready software
development.

Libraries of python:

 numpy: It is used to implement multi-dimensional arrays and used to implement


mathematical and logical operations on arrays.

 ii)matplotlib: It is used to visualize the data in the form of pie charts or graphs And It
is a plotting library in python numpy provide an environment.

 iii)networkx: It is a python library used to make graphs like directed and multigraphs
and we can perform operations on graphs.

Coding and testing:


Definition : Trimet graph based optimized topology named as TGO (Trimet graph
optimization) which is used to design a reliable, scalable, secure, simple, cost-effective
topology for engineering problems.

Algorithm:
Input: V={Dv, Hv, Sv }, Cn={Dvn, Hvn, Svn}
Output: Tg of Tg(TGO of TGO)
1. Start
2. Creations of n number of clusters with vertices set V of
a network.
3. Unequal Size clusters are formed using Fibonacci
sequence.
4. Apply Trimet graph algorithm recursively on each
cluster and also on dominant vertices Dvn in a
network
5. Trimet graph of Trimet graph (Tg of Tg) network is
generated.
6. Removing of Nodes randomly in an iterative process.
7.stop

Code for trimet or not:


from tkinter import *
from tkinter.ttk import *
import networkx as nx
import random
import matplotlib.pyplot as plt
import numpy as np

print("Enter size of matrix")


n=int(input())
L=[]
nodes=[]
for i in range(n):
l=[]
for j in range(n):
print("Is there edge between (",i,",",j,"):(1/0)")
x=int(input())
if x==1:
nodes.append((i,j))
l.append(x)
L.append(l)
print(L)
Degrees=[]
G=nx.Graph(nodes)
for i in range(n):
Degrees.append(G.degree(i))
print(Degrees)
c=0
cx=0
cy=0
for i in Degrees:
if i==n-1:
c=c+1
elif i==2:
cx=cx+1
elif i==3:
cy=cy+1
a=G.degree(0)
b=G.degree(1)
ab=G.degree(2)
if a==2 and b==2 and ab==2:
print("Odd Trimet")
else:
if n==4 and (c+cx+cy)==4 and c==2 and cx==n-2 and cy==0:
print("Even Trimet")
elif (c+cx+cy)==n and c==1 and cx==n-2 and cy==1:
print("Even Trimet")
elif (c+cx)==n and cy==0 and cx==n-1 and c==1:
print("Odd Trimet")
else:
print("Not a Trimet")

output:
for even trimet
For odd trimet
Visualization of star,wheel,TGO graph

from tkinter import *


from tkinter.ttk import *
import networkx as nx
import random
import matplotlib.pyplot as plt
import numpy as np
window = Tk()
window.title("Welcome to LikeGeeks app")
window.geometry('600x600')

def generate(parameter,nodes):
G1=nx.star_graph(nodes)
G2=nx.complete_graph(nodes)
G3=nx.wheel_graph(nodes)
if(parameter=="Diameter"):
height = [nx.diameter(G1),nx.diameter(G2),nx.diameter(G3)]
print(height)
elif(parameter=="Density"):
height = [nx.density(G1),nx.density(G2),nx.density(G3)]
print(height)
elif(parameter=="Avg Clustring"):
height =
[nx.average_clustering(G1),nx.average_clustering(G2),nx.average_clustering(G3)]
print(height)
elif(parameter=="Transitivity"):
height = [nx.transitivity(G1),nx.transitivity(G2),nx.transitivity(G3)]
print(height)
elif(parameter=="Edge Connectivity"):
height =
[nx.edge_connectivity(G1),nx.edge_connectivity(G2),nx.edge_connectivity(G3)]
print(height)
elif(parameter=="Avg Path Length"):
height =
[nx.average_shortest_path_length(G1),nx.average_shortest_path_length(G2),nx.average_shor
test_path_length(G3)]
print(height)
else:
print("nothing")
bars = ('Star', 'Complete','Wheel')
y_pos = np.arange(len(bars))
plt.bar(y_pos, height)
plt.xticks(y_pos, bars)
plt.show()

def compare():
newwin1 = Toplevel(window)
newwin1.title("Compare Window")
newwin1.geometry('800x600')
Label(newwin1, text="Select Graph to be compared: ").grid(column=1,row=1)
Checkbutton(newwin1, text="Star Graph").grid(column=2,row=1)
Checkbutton(newwin1, text="Trimet Graph").grid(column=3,row=1)
Checkbutton(newwin1, text="Wheel Graph").grid(column=4,row=1)
Checkbutton(newwin1, text="Complete Graph").grid(column=5,row=1)
Label(newwin1, text="Parameter 1: ").grid(column=1,row=2)
combo3 = Combobox(newwin1)
combo3['values']= ("Nodes", "Edges", "Degree","Avg
Degree","Diameter","Density","Transitivity","Avg Clustring","Edge Connectivity", "Avg
Path Length")
combo3.current(1)
combo3.grid(column=2, row=2)
btn = Button(newwin1, text="Compare",command=lambda:
generate(combo3.get(),int(combo4.get())))
btn.grid(column=4, row=2)
Label(newwin1, text="no of nodes: ").grid(column=3,row=2)
combo4 = Combobox(newwin1)
combo4['values']= (10,20,30,40,50,60,70)
combo4.current(0) #set the selected item
combo4.grid(column=4, row=3)

#Label(newwin1, text="Parameter 2: ").grid(column=1,row=3)


#combo3 = Combobox(newwin1)
#combo3['values']= ("Nodes", "Edges", "Degree","Avg
Degree","Diameter","Density","Transitivity","Avg Clustring","Edge Connectivity", "Avg
Path Length")
#combo3.current(1)
#combo3.grid(column=2, row=3)

def info(graph,node):
newwin = Toplevel(window)
newwin.title("Graph Information")
newwin.geometry('600x600')
if (graph=="Star graph"):
G3=nx.star_graph(int(node))
elif(graph=="Complet graph"):
G3=nx.complete_graph(int(node))
elif(graph=="Wheel graph"):
G3=nx.wheel_graph(int(node))
else:
print("nothing")
display = Label(newwin, text=str(nx.info(G3)))
display.grid(column=1,row=1)
display1 = Label(newwin, text="Diameter: "+str(nx.diameter(G3)))
display1.grid(column=1,row=2)
display3 = Label(newwin, text="Density: "+str(nx.density(G3)))
display3.grid(column=1,row=3)
display4 = Label(newwin, text="Average Clustring: "+str(nx.average_clustering(G3)))
display4.grid(column=1,row=4)
display5 = Label(newwin, text="Transitivity: "+str(nx.transitivity(G3)))
display5.grid(column=1,row=5)
display6 = Label(newwin, text="Edge_connectivity: "+str(nx.edge_connectivity(G3)))
display6.grid(column=1,row=6)
display7 = Label(newwin, text="average_path_length:
"+str(nx.average_shortest_path_length(G3, weight=None)))
display7.grid(column=1,row=7)

def Trimet(n):
#n=n+1
l=[]
for i in range(1,n):
l.append((0,i))
if n%2==0 and n>2:
n=n-1
for i in range(1,n,2):
l.append((i,i+1))
l.append((n-1,n))
elif n%2==1 and n>2:
n=n+1
for i in range(1,n-1,2):
l.append((i,i+1))
#l.append((n-1,n))
return l
def do(graph,node):
lbl = Label(window, text=graph+" with "+node+" nodes ")
lbl.grid(column=1, row=5)

if (graph=="Star graph"):
G3=nx.star_graph(int(node)-1)
elif(graph=="Complet graph"):
G3=nx.complete_graph(int(node))
elif(graph=="Wheel graph"):
G3=nx.wheel_graph(int(node))
elif(graph=="Trimet graph"):
nodex=Trimet(int(node))
G3=nx.Graph(nodex)
else:
print("nothing")

#G3 = nx.random_regular_graph(4, 50)


#G3=nx.barabasi_albert_graph(50,4)
#G3=nx.complete_graph(50)
#G3= nx.Graph([(0, 1), (0, 2), (1, 2), (0, 3), (0, 4), (4, 3),(0,5),(0,6),(5,6),(0,7),(0,8),
(7,8),(0,9),(0,10),(9,10),(11,12),(11,13),(12,13),(11,14),(11,15),(14,15),(11,16),(11,17),
(16,17),(11,18),(11,19),(18,19),(0,11),(11,31),(0,31),(20,21),(20,22),(21,22),(20,23),(20,24),
(23,24),(20,25),(20,26),(25,26),(20,27),(20,28),(27,28),(20,29),(20,30),(29,30),(0,20),(11,31),
(31,32),(31,33),(32,33),(31,34),(31,35),(34,35),(31,36),(31,37),(36,37),(31,38),(31,39),
(38,39),(31,40),(40,41),(40,42),(40,43),(41,42),(42,43),(40,44),(40,45),(44,45),(40,46),
(40,47),(46,47),(40,48),(40,49),(48,49),(31,50),(50,51),(50,52),(51,52),(50,53),(50,54),
(53,54),(50,55),(50,56),(55,56),(50,57),(50,58),(57,58),(59,60),(59,61),(60,61),(59,62),
(59,63),(62,63),(59,64),(59,65),(64,65),(50,59),(66,67),(66,68),(67,68),(66,69),(66,70),
(59,66),(20,40),(20,31),(40,31),(50,31),(59,31),(66,59),(31,66)])
#G3= nx.Graph([(1,2), (1,3), (1,4), (2,5), (2,6), (2,7), (3,8), (3,9), (4,10),(5,11),
(5,12), (6,13),(6,14),(7,15),(7,16),(7,17),(8,18),(8,19),(8,20),(9,21),(9,22),(9,23),(10,24),
(10,25),(10,26),(10,27),(10,28),(11,29),(12,30),(12,31),(13,32),(13,33)])
#G3= nx.Graph([(0, 1), (0, 2), (0, 3), (0,4), (0,6),(6,5),(6,7),(6,8),(6,9),(6,10),(6,11),
(11,12),(11,13),(11,14),(11,15),(11,16),(16,17),(16,18),(16,19),(16,20),(16,21),(16,22),(0,23),
(23,24),(23,25),(23,26),(23,27),(23,28),(23,29),(29,30),(29,31),(29,32),(29,33),(29,34),
(29,35),(11,36),(36,37),(36,38),(36,39),(36,40),(16,41),(41,42),(41,43),(41,44),(41,45),
(41,46),(41,47),(41,48),(41,49),(41,50),(6,51),(51,52),(51,53),(51,54),(51,55),(51,56),(51,57),
(51,58),(6,59),(59,60),(59,61),(59,62),(59,63),(59,64),(59,65),(59,66),(59,67),(59,68),(59,69),
(59,70)])
#G3=nx.dorogovtsev_goltsev_mendes_graph(5)
#G3=nx.watts_strogatz_graph(n, k, p, seed=None)
ListOfNodes = G3.nodes()
NumberofNodes = G3.number_of_nodes()
nx.draw_networkx(G3, with_labels=True)
plt.show()
lbl = Label(window, text="Select Graph")
lbl.grid(column=1, row=1)
lbl2 = Label(window, text="Select No of Nodes")
lbl2.grid(column=1, row=2)
lbl3 = Label(window, text="Visulize Graph")
lbl3.grid(column=1, row=3)
lbl4 = Label(window, text="Graph Information")
lbl4.grid(column=1, row=4)
#txt = Entry(window,width=10)
#txt.grid(column=1, row=0)
combo = Combobox(window)
combo['values']= ("Star graph", "Trimet graph", "Wheel graph","Complet graph")
combo.current(1) #set the selected item
combo.grid(column=2, row=1)
combo1 = Combobox(window)
combo1['values']= (4,5,7,10,20,30,40,50,60,70,100)
combo1.current(0) #set the selected item
combo1.grid(column=2, row=2)
btn = Button(window, text="Check")
btn.grid(column=3, row=1)
btn = Button(window, text="Visulize graph Model",command=lambda:
do(combo.get(),combo1.get()))
btn.grid(column=2, row=3)
btn1 = Button(window, text="Graph Information",command=lambda:
info(combo.get(),combo1.get()))
btn1.grid(column=2, row=4)
btn1 = Button(window, text="Compare with related work",command=compare)
btn1.grid(column=2, row=5)
window.mainloop()

outputs:
Graph info of Star,Wheel,TGO graph:
Visualization of star of star, star of TGO,TGO of star, TGO of TGO Graphs:

from tkinter import *


from tkinter.ttk import *
import networkx as nx
import random
import matplotlib.pyplot as plt
import numpy as np

window = Tk()
window.title("Welcome to LikeGeeks app")
window.geometry('600x600')

def generate(parameter,nodes):
G1=nx.star_graph(nodes)
G2=nx.complete_graph(nodes)
G3=nx.wheel_graph(nodes)
if(parameter=="Diameter"):
height = [nx.diameter(G1),nx.diameter(G2),nx.diameter(G3)]
print(height)
elif(parameter=="Density"):
height = [nx.density(G1),nx.density(G2),nx.density(G3)]
print(height)
elif(parameter=="Avg Clustring"):
height =
[nx.average_clustering(G1),nx.average_clustering(G2),nx.average_clustering(G3)]
print(height)
elif(parameter=="Transitivity"):
height = [nx.transitivity(G1),nx.transitivity(G2),nx.transitivity(G3)]
print(height)
elif(parameter=="Edge Connectivity"):
height =
[nx.edge_connectivity(G1),nx.edge_connectivity(G2),nx.edge_connectivity(G3)]
print(height)
elif(parameter=="Avg Path Length"):
height =
[nx.average_shortest_path_length(G1),nx.average_shortest_path_length(G2),nx.average_shor
test_path_length(G3)]
print(height)
else:
print("nothing")
bars = ('Star', 'Complete','Wheel')
y_pos = np.arange(len(bars))
plt.bar(y_pos, height)
plt.xticks(y_pos, bars)
plt.show()

def compare():
newwin1 = Toplevel(window)
newwin1.title("Compare Window")
newwin1.geometry('800x600')
Label(newwin1, text="Select Graph to be compared: ").grid(column=1,row=1)
Checkbutton(newwin1, text="Star Graph").grid(column=2,row=1)
Checkbutton(newwin1, text="Trimet Graph").grid(column=3,row=1)
Checkbutton(newwin1, text="Wheel Graph").grid(column=4,row=1)
Checkbutton(newwin1, text="Complete Graph").grid(column=5,row=1)
Label(newwin1, text="Parameter 1: ").grid(column=1,row=2)
combo3 = Combobox(newwin1)
combo3['values']= ("Nodes", "Edges", "Degree","Avg
Degree","Diameter","Density","Transitivity","Avg Clustring","Edge Connectivity", "Avg
Path Length")
combo3.current(1)
combo3.grid(column=2, row=2)
btn = Button(newwin1, text="Compare",command=lambda:
generate(combo3.get(),int(combo4.get())))
btn.grid(column=4, row=2)
Label(newwin1, text="no of nodes: ").grid(column=3,row=2)
combo4 = Combobox(newwin1)
combo4['values']= (10,20,30,40,50,60,70)
combo4.current(0) #set the selected item
combo4.grid(column=4, row=3)

#Label(newwin1, text="Parameter 2: ").grid(column=1,row=3)


#combo3 = Combobox(newwin1)
#combo3['values']= ("Nodes", "Edges", "Degree","Avg
Degree","Diameter","Density","Transitivity","Avg Clustring","Edge Connectivity", "Avg
Path Length")
#combo3.current(1)
#combo3.grid(column=2, row=3)

def info(graph,node):
newwin = Toplevel(window)
newwin.title("Graph Information")
newwin.geometry('600x600')
if (graph=="Star graph"):
G3=nx.star_graph(int(node))
elif(graph=="Complet graph"):
G3=nx.complete_graph(int(node))
elif(graph=="Wheel graph"):
G3=nx.wheel_graph(int(node))
else:
print("nothing")
display = Label(newwin, text=str(nx.info(G3)))
display.grid(column=1,row=1)
display1 = Label(newwin, text="Diameter: "+str(nx.diameter(G3)))
display1.grid(column=1,row=2)
display3 = Label(newwin, text="Density: "+str(nx.density(G3)))
display3.grid(column=1,row=3)
display4 = Label(newwin, text="Average Clustring: "+str(nx.average_clustering(G3)))
display4.grid(column=1,row=4)
display5 = Label(newwin, text="Transitivity: "+str(nx.transitivity(G3)))
display5.grid(column=1,row=5)
display6 = Label(newwin, text="Edge_connectivity: "+str(nx.edge_connectivity(G3)))
display6.grid(column=1,row=6)
display7 = Label(newwin, text="average_path_length:
"+str(nx.average_shortest_path_length(G3, weight=None)))
display7.grid(column=1,row=7)

def Star(a,n):
l=[]
for i in range(a,n):
l.append((a,i))
return l
def SOS(n):
Fs=[]
a=3
b=5
Fs.append(a)
Fs.append(b)
for i in range(18):
c=a+b
a=b
b=c
Fs.append(c)
x=0
X=[]
L=[]
s=Fs[0]
abc=0
for i in range(1,len(Fs)):
if s>n:
break
else:
X.append(x)
b=Star(x,s)
L.append(b)
x=s
s=s+Fs[i]
abc=abc+Fs[i-1]
l=[]
if n-x<2:
pass
elif n-x>2:
X.append(x)
na=n-x
abc=[]
for i in range(x,n):
abc.append(i)
for i in range(1,na):
l.append((abc[0],abc[i]))
L.append(l)
h=X[0]
hx=[]
for i in range(1,len(X)):
hx.append((h,X[i]))
L.append(hx)
return L
def StarOfStars(n):
L=SOS(n)
Fs=[]
for i in L:
for j in i:
Fs.append(j)
return Fs
def Trimet(a,n):
#n=n+1
l=[]
for i in range(a,n):
l.append((a,i))
if n%2==0 and n>2:
n=n-1
for i in range(a+1,n,2):
l.append((i,i+1))
l.append((n-1,n))
elif n%2==1 and n>2:
n=n+1
for i in range(a+1,n-1,2):
l.append((i,i+1))
#l.append((n-1,n))
return l
def TrimetOfTrimet(n):
Fs=[]
a=3
b=5
Fs.append(a)
Fs.append(b)
for i in range(18):
c=a+b
a=b
b=c
Fs.append(c)
x=0
X=[]
L=[]
s=Fs[0]
abc=0
x=0
for i in range(1,len(Fs)):
if s>n:
break
else:
X.append(x)
b=Trimet(x,s)
L.append(b)
x=s
s=s+Fs[i]
abc=abc+Fs[i-1]
l=[]
if n-x<2:
pass
elif n-x>2:
X.append(x)
na=n-x
abc=[]
for i in range(x,n):
abc.append(i)
if na%2==0 and na>2:
for i in range(1,na):
l.append((abc[0],abc[i]))
print("a=",l)
na=na-1
for i in range(1,na,2):
l.append((abc[i],abc[i+1]))
l.append((abc[na-1],abc[na]))
elif na%2==1 and na>2:
na=na+1
for i in range(1,na-1):
l.append((abc[0],abc[i]))
for i in range(1,na-1,2):
l.append((abc[i],abc[i+1]))
#l.append((n-1,n))
L.append(l)
Y=X[0]
Z=X[1]
l=[]
for i in range(len(X)):
l.append((Y,X[i]))
n=len(X)
if n%2==0 and n>2:
n=n-1
for i in range(1,n,2):
l.append((X[i],X[i+1]))
l.append((X[n-1],X[n]))
elif n%2==1 and n>2:
n=n+1
for i in range(1,n-1,2):
l.append((X[i],X[i+1]))
#l.append((n-1,n))
L.append(l)
Fs=[]
for i in L:
for j in i:
Fs.append(j)
return Fs
def StarOfTrimet(n):
NumberOfNodes=5
a=0
c=1
L=[]
X=[]
d=int(n/NumberOfNodes)
for i in range(d):
X.append(a)
b=Trimet(a,NumberOfNodes*c)
c=c+1
a=a+NumberOfNodes
L.append(b)
return L
def SOT(n):
L=StarOfTrimet(n)
t1=[]
for i in L:
for j in i:
if j[0]==j[1]:
t1.append(j[0])
Fs1=[]
for i in L:
for j in i:
Fs1.append(j)
x=t1[0]
for i in range(1,len(t1)):
Fs1.append((x,t1[i]))
return Fs1

def TrimetOfStars(n):
Fs=[]
a=3
b=5
for i in range(18):
c=a+b
a=b
b=c
Fs.append(c)
x=0
X=[]
L=[]
s=Fs[0]
abc=0
for i in range(1,len(Fs)):
if s>n:
break
else:
X.append(x)
b=Star(x,s)
L.append(b)
x=s
s=s+Fs[i]
abc=abc+Fs[i-1]
l=[]
if n-x<1:
pass
elif n-x>1:
X.append(x)
na=n-x
abc=[]
for i in range(x,n):
abc.append(i)
for i in range(1,na):
l.append((abc[0],abc[i]))
L.append(l)
a=X[0]
n=len(X)
l=[]
for i in range(a,n):
l.append((X[a],X[i]))
if n%2==0 and n>2:
n=n-1
for i in range(a+1,n,2):
l.append((X[i],X[i+1]))
l.append((X[n-1],X[n]))
elif n%2==1 and n>2:
n=n+1
for i in range(a+1,n-1,2):
l.append((X[i],X[i+1]))
L.append(l)
f=[]
for i in L:
for j in i:
f.append(j)
return f

def StarOfWheel(n):
Fs=[]
a=3
b=5
Fs.append(a)
Fs.append(b)
for i in range(18):
c=a+b
a=b
b=c
Fs.append(c)
x=0
X=[]
L=[]
s=Fs[0]
abc=0
for i in range(1,len(Fs)):
if s>n:
break
else:
X.append(x)
b=Star(x,s)
L.append(b)
x=s
s=s+Fs[i]
abc=abc+Fs[i-1]
l=[]
if n-x<2:
pass
elif n-x>2:
X.append(x)
na=n-x
abc=[]
for i in range(x,n):
abc.append(i)
for i in range(1,na):
l.append((abc[0],abc[i]))
L.append(l)
h=X[0]
hx=[]
for i in range(1,len(X)):
hx.append((h,X[i]))
for i in range(1,len(X)-1):
hx.append((X[i],X[i+1]))
i=i+1
hx.append((X[1],X[len(X)-1]))
L.append(hx)
Lx=[]
for i in L:
for j in i:
Lx.append(j)
return Lx
def WheelOfStar(n):
temp=TOS(n)
l=temp[1]
Fs=[]
for i in temp[0]:
Fs.append(i)
x=l[0]
for i in range(1,len(l)):
Fs.append((x,l[i]))
for i in range(1,len(l)-1):
Fs.append((l[i],l[i+1]))
i=i+1
Fs.append((l[1],l[len(l)-1]))
return Fs
def TrimetOfWheel(n):
l=StarOfTrimet(n)
y=[]
Fs=[]
for i in l:
for j in i:
if j[0]==j[1]:
y.append(j[0])
Fs.append(j)
x=y[0]
for i in range(1,len(y)):
Fs.append((x,y[i]))
for i in range(1,len(y)-1):
Fs.append((y[i],y[i+1]))
i=i+1
Fs.append((y[1],y[len(y)-1]))
return Fs
def Wheel(a,n):
l=[]
for i in range(a,n):
l.append((a,i))
for i in range(a+1,n-1):
l.append((i,i+1))
l.append((n-1,a+1))
return l
def WOWx(n):
Fs=[]
a=5
b=8
Fs.append(a)
Fs.append(b)
for i in range(18):
c=a+b
a=b
b=c
Fs.append(c)
x=0
X=[]
L=[]
s=Fs[0]
abc=0
for i in range(1,len(Fs)):
if s>n:
break
else:
X.append(x)
b=Wheel(x,s)
L.append(b)
x=s
s=s+Fs[i]
abc=abc+Fs[i-1]
l=[]
if n-x<4:
pass
elif n-x>=4:
X.append(x)
na=n-x
abc=[]
for i in range(x,n):
abc.append(i)
for i in range(0,na):
l.append((abc[0],abc[i]))
for i in range(1,na-1):
l.append((abc[i],abc[i+1]))
#l.append((0,abc[0]))
L.append(l)
return L
def WOW(n):
Fs=[]
a=5
b=8
Fs.append(a)
Fs.append(b)
for i in range(18):
c=a+b
a=b
b=c
Fs.append(c)
x=0
X=[]
L=[]
s=Fs[0]
abc=0
for i in range(1,len(Fs)):
if s>n:
break
else:
X.append(x)
b=Wheel(x,s)
L.append(b)
x=s
s=s+Fs[i]
return L
def WheelOfWheel(n):
l=WOWx(n)
y=[]
Fs=[]
for i in l:
for j in i:
if j[0]==j[1]:
y.append(j[0])
Fs.append(j)
x=y[0]
for i in range(1,len(y)):
Fs.append((x,y[i]))
for i in range(1,len(y)-1):
Fs.append((y[i],y[i+1]))
i=i+1
Fs.append((y[1],y[len(y)-1]))
return Fs
def WheelOfStar(n):
l=WOWx(n)
y=[]
Fs=[]
for i in l:
for j in i:
if j[0]==j[1]:
y.append(j[0])
Fs.append(j)
x=y[0]
for i in range(1,len(y)):
Fs.append((x,y[i]))
return Fs
def WheelOfTrimet(n):
L=WOWx(n)
X=[]
Fs=[]
for i in L:
for j in i:
if j[0]==j[1]:
X.append(j[0])
Fs.append(j)
Y=X[0]
Z=X[1]
l=[]
for i in range(len(X)):
l.append((Y,X[i]))
n=len(X)
if n%2==0 and n>2:
n=n-1
for i in range(1,n,2):
l.append((X[i],X[i+1]))
l.append((X[n-1],X[n]))
elif n%2==1 and n>2:
n=n+1
for i in range(1,n-1,2):
l.append((X[i],X[i+1]))
#l.append((n-1,n))
L.append(l)
Fs=[]
for i in L:
for j in i:
Fs.append(j)
return Fs
def do(graph,node):
lbl = Label(window, text=graph+" with "+node+" nodes ")
lbl.grid(column=1, row=5)
X=0
def Fibonnacix(xx,n):
lx=[]
a=3
b=5
l=[]
l.append(a)
l.append(b)
for i in range(15):
c=a+b
a=b
b=c
l.append(c)
x=0
for j in range(xx):
x=x+l[j]
for j in range(xx,15):
y=x+l[j]
x=y
lx.append(y)
return lx
if(graph=="Star of stars"):
nodex=StarOfStars(int(node))
G3=nx.Graph(nodex)
ly=Fibonnacix(2,15)
elif(graph=="TrimetOfTrimet"):
ly=Fibonnacix(2,15)
nodex=TrimetOfTrimet(int(node))
G3=nx.Graph(nodex)
elif(graph=="Star of Trimet"):
ly=Fibonnacix(2,15)
nodex=TrimetOfStars(int(node))
G3=nx.Graph(nodex)
elif(graph=="Trimet of Stars"):
ly=Fibonnacix(2,15)
nodex=SOT(int(node))
G3=nx.Graph(nodex)
elif(graph=="Wheel of Star"):
ly=Fibonnacix(2,15)
nodex=WheelOfStar(int(node))
G3=nx.Graph(nodex)
elif(graph=="Trimet of Wheel"):
ly=Fibonnacix(3,15)
nodex=TrimetOfWheel(int(node))
G3=nx.Graph(nodex)
elif(graph=="Wheel of Wheel"):
ly=Fibonnacix(4,15)
nodex=WheelOfWheel(int(node))
G3=nx.Graph(nodex)
elif(graph=="Star Of Wheel"):
ly=Fibonnacix(3,15)
nodex=StarOfWheel(int(node))
G3=nx.Graph(nodex)
elif(graph=="Wheel of Trimet"):
ly=Fibonnacix(3,15)
nodex=WheelOfTrimet(int(node))
G3=nx.Graph(nodex)
else:
print("nothing")

#G3 = nx.random_regular_graph(4, 50)


#G3=nx.barabasi_albert_graph(50,4)
#G3=nx.complete_graph(50)
#G3= nx.Graph([(0, 1), (0, 2), (1, 2), (0, 3), (0, 4), (4, 3),(0,5),(0,6),(5,6),(0,7),(0,8),
(7,8),(0,9),(0,10),(9,10),(11,12),(11,13),(12,13),(11,14),(11,15),(14,15),(11,16),(11,17),
(16,17),(11,18),(11,19),(18,19),(0,11),(11,31),(0,31),(20,21),(20,22),(21,22),(20,23),(20,24),
(23,24),(20,25),(20,26),(25,26),(20,27),(20,28),(27,28),(20,29),(20,30),(29,30),(0,20),(11,31),
(31,32),(31,33),(32,33),(31,34),(31,35),(34,35),(31,36),(31,37),(36,37),(31,38),(31,39),
(38,39),(31,40),(40,41),(40,42),(40,43),(41,42),(42,43),(40,44),(40,45),(44,45),(40,46),
(40,47),(46,47),(40,48),(40,49),(48,49),(31,50),(50,51),(50,52),(51,52),(50,53),(50,54),
(53,54),(50,55),(50,56),(55,56),(50,57),(50,58),(57,58),(59,60),(59,61),(60,61),(59,62),
(59,63),(62,63),(59,64),(59,65),(64,65),(50,59),(66,67),(66,68),(67,68),(66,69),(66,70),
(59,66),(20,40),(20,31),(40,31),(50,31),(59,31),(66,59),(31,66)])
#G3= nx.Graph([(1,2), (1,3), (1,4), (2,5), (2,6), (2,7), (3,8), (3,9), (4,10),(5,11),
(5,12), (6,13),(6,14),(7,15),(7,16),(7,17),(8,18),(8,19),(8,20),(9,21),(9,22),(9,23),(10,24),
(10,25),(10,26),(10,27),(10,28),(11,29),(12,30),(12,31),(13,32),(13,33)])
#G3= nx.Graph([(0, 1), (0, 2), (0, 3), (0,4), (0,6),(6,5),(6,7),(6,8),(6,9),(6,10),(6,11),
(11,12),(11,13),(11,14),(11,15),(11,16),(16,17),(16,18),(16,19),(16,20),(16,21),(16,22),(0,23),
(23,24),(23,25),(23,26),(23,27),(23,28),(23,29),(29,30),(29,31),(29,32),(29,33),(29,34),
(29,35),(11,36),(36,37),(36,38),(36,39),(36,40),(16,41),(41,42),(41,43),(41,44),(41,45),
(41,46),(41,47),(41,48),(41,49),(41,50),(6,51),(51,52),(51,53),(51,54),(51,55),(51,56),(51,57),
(51,58),(6,59),(59,60),(59,61),(59,62),(59,63),(59,64),(59,65),(59,66),(59,67),(59,68),(59,69),
(59,70)])
#G3=nx.dorogovtsev_goltsev_mendes_graph(5)
#G3=nx.watts_strogatz_graph(n, k, p, seed=None)
ListOfNodes = G3.nodes()
NumberofNodes = G3.number_of_nodes()
nx.draw_networkx(G3, with_labels=True)
plt.show()
lbl = Label(window, text="Select Graph")
lbl.grid(column=1, row=1)
lbl2 = Label(window, text="Select No of Nodes")
lbl2.grid(column=1, row=2)
lbl3 = Label(window, text="Visulize Graph")
lbl3.grid(column=1, row=3)
lbl4 = Label(window, text="Graph Information")
lbl4.grid(column=1, row=4)
#txt = Entry(window,width=10)
#txt.grid(column=1, row=0)
combo = Combobox(window)
combo['values']= ("Star graph", "Star of Trimet","Star of stars","TrimetOfTrimet","Trimet of
Stars","Wheel of Star","Trimet of Wheel","Wheel of Wheel","Star Of Wheel","Wheel of
Trimet")
combo.current(1) #set the selected item
combo.grid(column=2, row=1)
combo1 = Combobox(window)
combo1['values']=(16,29,50,84,100,1000)
combo1.current(0) #set the selected item
combo1.grid(column=2, row=2)
btn = Button(window, text="Check")
btn.grid(column=3, row=1)
btn = Button(window, text="Visulize graph Model",command=lambda:
do(combo.get(),combo1.get()))
btn.grid(column=2, row=3)
btn1 = Button(window, text="Graph Information",command=lambda:
info(combo.get(),combo1.get()))
btn1.grid(column=2, row=4)
btn1 = Button(window, text="Compare with related work",command=compare)
btn1.grid(column=2, row=5)
window.mainloop()

output:
Graph info of star of star,star of TGO,TGO of star,TGO of TGO graphs:
Scalability:
Survivabiity:
Conclusion:

In network world there is problem called scalability which can be addressed by graph
theory,game theory,machine learning,artificial intelligence.

We addressed the problem through graph theory and prepared model(trimet graph) as TGO
TOPOLOGY as solution.
References :

Reference paper of shanmukh srinivas.A

You might also like