Graph Analytics and Complexity
Questions and Answers
by
Dr.Animesh Chaturvedi
Assistant Professor: LNMIIT Jaipur
Post Doctorate: King’s College London &TheAlanTuring Institute
PhD: IIT Indore
Answers of Fill in the Blank
Answers of Match The Column
Answers of Match The Column
Answers of Fill in the Blank
Answers of Match The Column
Q5
Q5
A5
There could be many ways to answer this question. For example
• CG1: the number of incoming edges to that function, the priority of
calling a procedures, number of variables function B inherits from
function A, time required to call, cost of calling a procedure by a caller
procedure, time or duration of call or request between two
procedures, etc.
• WN2: frequency of the word, memory required to store a word, cost
we must spend in order to connect, number of conjunction between
words.
A5
MST3) Average-MST(G1, G2, G3)
n = size of G1
M1 = Prim's-MST(G1)
M2 = Prim's-MST(G2)
M3 = Prim's-MST(G3)
G[n, n] <- Graph
for i=1 to n
for j=1 to n
if M1[i][j]==1 or M2[i][j]==1 or M3[i][j]==1
G[i,j] = 1
else
G[i,j] = 0
return Prim's-MST(G)
A5
SP4) Average-SSSP(G1, G2, G3)
n = size of G1
D1 = Dijkstra's-SP(G1)
D2 = Dijkstra's-SP(G2)
D3 = Dijkstra's-SP(G3)
G[n, n] <- Graph
for i=1 to n
for j=1 to n
if D1[i][j]==1 or D2[i][j]==1 or D3[i][j]==1
G[i,j] = 1
else
G[i,j] = 0
return Dijkstra's-SP(G)
A5
MST3
int Average-MST(Graph* G1,Graph* G2,Graph* G3){
int min_g1=Algorithm_Prim_MST(G1);
int min_g2=Algorithm_Prim_MST(G2);
int min_g3=Algorithm_Prim_MST(G3);
return (min_g1+min_g2+min_g3)/3;
}
SP4
A5
MST3: AVG_MST(Graph G1, Graph G2, Graph G3):
MST1=Algorithm Prim's-MST(G1)
MST2=Algorithm Prim's-MST(G2)
MST3=Algorithm Prim's-MST(G3)
avgMST=ceil((MST1+MST2+MST3)/3)
return avgMST
MST for G1=12, G2=10, G3=10
AVG MST=(12+10+10)/3=10.66 or 11 weight
A5
SP4: Average-SSSP(Graph G1, Graph G2, Graph G3):
SP1[]=Algorithm Dijkstra's-SP(G1);
SP2[]=Algorithm Dijkstra's-SP(G2);
SP3[]=Algorithm Dijkstra's-SP(G3);
SP4[]=ceil((sum of element at index i in SP1[], SP2[], SP3[])/3) for i=1
to no. of vertices
return SP4[]
A5
MST3
Get MSTs of all the graphs. Combine their edges to make a new graph. Find the MST of this new graph.
Algorithm:
mst1 = PrimsMST(G1)
mst2 = PrimsMST(G2)
mst3 = PrimsMST(G3)
Graph G = new Graph(V: 6)
for all edges of mst1 do
insert edge in G
for all edges of mst2 do
insert edge in G
for all edges of mst2 do
insert edge in G
Graph avgMST = PrimsMST(G);
return avgMST
A5
SP4
Get the single source shortest path(SSSP) of all the graphs. After that, the
shortest path for each of the nodes can be taken as the minimum of the 3
SSSPs derived from the given graphs for the required vertex.
Algorithm:
for v of vertex 2 to 6 do
sssp1 = DijkstraSP(G1, 1, v)
sssp2 = DijkstraSP(G2, 1, v)
sssp3 = DijkstraSP(G3, 1, v)
avgSSSP[v] = min(sssp1, sssp2, sssp3)
end
A5
MST3. Make MST of the three graphs. Then we find the distance between two vertices on all those MST, take
there average and form a direct edge between those vertices with weight of that edge being the average
calculated earlier. We do this for every vertices pair. The resultant structure would be a completely connected
graph. We take the MST of this graph and that would be the result.
1 Average MST(G1,G2,G3):
2 GM1= Algorithm Prim's-MST(G1)
3 GM2= Algorithm Prim's-MST(G2)
4 GM3= Algorithm Prim's-MST(G3)
5 for all vertices(u, v) // u and v are vertices are one vertices pair
6 w=distance(u,v,GM1,GM2,GM3) // takes average of sum distance
7 Add(A, u, v, w) // Add edge of weight w between u and v in a graph A
8 return Algorithm Prim's-MST(A)
This would help us in order to understand what the average performance and space consumption by all three
methods. It would also tell us how every function is connected to one another and what should be the most
optimal way to define variables.
A5
SP4. The approach would be like that of Average-MST
We take Shortest Path between all vertices of the three graphs. Then we find the distance between
two vertices on all those graphs, take there average and form an edge between those vertices with
weight of that edge being the average calculated earlier. We do this for every vertices pair. The
resultant structure would be a completely connected graph. We take the shortest path of this graph
and that would be the result.
1 Average SSSP(G1,G2,G3):
2 GM1= Algorithm Dijkstra-SP(G1)
3 GM2= Algorithm Dijkstra-SP(G2)
4 GM3= Algorithm Dijkstra-SP(G3)
5 for all vertices(u,v) // u and v are vertices are one vertice pair
6 w=distance(u,v,GM1,GM2,GM3) // takes average of sum distance
7 Add(A,u,v,w) // Add edge of weight w between u and v in a graph A
8 return Algorithm Dijkstra-SP(A)
Q6
A6
• NP1) Calculate probability of each edge.
• NP2) Not reducible to TSP or any other NPC. Because the NP1 is a
simple problem that can be solved by calculating probability (for this
we need to traverse back to the same node, which is not allowed in
TSP), whereas NPCs are NP hard problems.
Q7
A7
AKS1
• The key idea of AKS primality test is to find the coefficient of xi in ((x+a)n - (xn + a)). If all
coefficients are multiple of n, then n is prime else composite number.
• To get internal elements, remove first and last elements of each row in a Pascal triangle. For a nth
row of a Pascal triangle, the internal element are the coefficients of above equation with a = -1,
then the equation ((x-1)n - (xn -1))
AKS2 For N=19
• ((x-1)19- (x19 -1)) = -19x18 + 171x17 - 969x16 + 3876x15 - 11628x14 + 27132x13 - 50388x12 + 75582x11 -
92378x10 + 92378x9 - 75582x8 + 50388x7 - 27132x6 + 11628x5 - 3876x4 + 969x3 - 171x2 + 19x.
• The coefficient of equation or the internal elements of Pascal triangle row: 1, 19, 171, 969, 3876,
11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1
• Here, each the coefficient or the internal element is the multiple of 19. Therefore, 19 is a prime
number as per AKS.
Q8 and A8
Q9 and A9
Q10 and A10
Q11 and A11
Thank You
Japanese
Hebrew
English
Merci
French
Russian
Danke
German
Grazie
Italian
Gracias
Spanish
Obrigado
Portuguese
Arabic
Simplified
Chinese
Traditional
Chinese
Tamil
Thai
Korean
https://sites.google.com/site/animeshchaturvedi07

Graph Analytics and Complexity Questions and answers

  • 1.
    Graph Analytics andComplexity Questions and Answers by Dr.Animesh Chaturvedi Assistant Professor: LNMIIT Jaipur Post Doctorate: King’s College London &TheAlanTuring Institute PhD: IIT Indore
  • 2.
    Answers of Fillin the Blank
  • 3.
    Answers of MatchThe Column
  • 4.
    Answers of MatchThe Column
  • 5.
    Answers of Fillin the Blank
  • 6.
    Answers of MatchThe Column
  • 7.
  • 8.
  • 9.
    A5 There could bemany ways to answer this question. For example • CG1: the number of incoming edges to that function, the priority of calling a procedures, number of variables function B inherits from function A, time required to call, cost of calling a procedure by a caller procedure, time or duration of call or request between two procedures, etc. • WN2: frequency of the word, memory required to store a word, cost we must spend in order to connect, number of conjunction between words.
  • 10.
    A5 MST3) Average-MST(G1, G2,G3) n = size of G1 M1 = Prim's-MST(G1) M2 = Prim's-MST(G2) M3 = Prim's-MST(G3) G[n, n] <- Graph for i=1 to n for j=1 to n if M1[i][j]==1 or M2[i][j]==1 or M3[i][j]==1 G[i,j] = 1 else G[i,j] = 0 return Prim's-MST(G)
  • 11.
    A5 SP4) Average-SSSP(G1, G2,G3) n = size of G1 D1 = Dijkstra's-SP(G1) D2 = Dijkstra's-SP(G2) D3 = Dijkstra's-SP(G3) G[n, n] <- Graph for i=1 to n for j=1 to n if D1[i][j]==1 or D2[i][j]==1 or D3[i][j]==1 G[i,j] = 1 else G[i,j] = 0 return Dijkstra's-SP(G)
  • 12.
    A5 MST3 int Average-MST(Graph* G1,Graph*G2,Graph* G3){ int min_g1=Algorithm_Prim_MST(G1); int min_g2=Algorithm_Prim_MST(G2); int min_g3=Algorithm_Prim_MST(G3); return (min_g1+min_g2+min_g3)/3; } SP4
  • 13.
    A5 MST3: AVG_MST(Graph G1,Graph G2, Graph G3): MST1=Algorithm Prim's-MST(G1) MST2=Algorithm Prim's-MST(G2) MST3=Algorithm Prim's-MST(G3) avgMST=ceil((MST1+MST2+MST3)/3) return avgMST MST for G1=12, G2=10, G3=10 AVG MST=(12+10+10)/3=10.66 or 11 weight
  • 14.
    A5 SP4: Average-SSSP(Graph G1,Graph G2, Graph G3): SP1[]=Algorithm Dijkstra's-SP(G1); SP2[]=Algorithm Dijkstra's-SP(G2); SP3[]=Algorithm Dijkstra's-SP(G3); SP4[]=ceil((sum of element at index i in SP1[], SP2[], SP3[])/3) for i=1 to no. of vertices return SP4[]
  • 15.
    A5 MST3 Get MSTs ofall the graphs. Combine their edges to make a new graph. Find the MST of this new graph. Algorithm: mst1 = PrimsMST(G1) mst2 = PrimsMST(G2) mst3 = PrimsMST(G3) Graph G = new Graph(V: 6) for all edges of mst1 do insert edge in G for all edges of mst2 do insert edge in G for all edges of mst2 do insert edge in G Graph avgMST = PrimsMST(G); return avgMST
  • 16.
    A5 SP4 Get the singlesource shortest path(SSSP) of all the graphs. After that, the shortest path for each of the nodes can be taken as the minimum of the 3 SSSPs derived from the given graphs for the required vertex. Algorithm: for v of vertex 2 to 6 do sssp1 = DijkstraSP(G1, 1, v) sssp2 = DijkstraSP(G2, 1, v) sssp3 = DijkstraSP(G3, 1, v) avgSSSP[v] = min(sssp1, sssp2, sssp3) end
  • 17.
    A5 MST3. Make MSTof the three graphs. Then we find the distance between two vertices on all those MST, take there average and form a direct edge between those vertices with weight of that edge being the average calculated earlier. We do this for every vertices pair. The resultant structure would be a completely connected graph. We take the MST of this graph and that would be the result. 1 Average MST(G1,G2,G3): 2 GM1= Algorithm Prim's-MST(G1) 3 GM2= Algorithm Prim's-MST(G2) 4 GM3= Algorithm Prim's-MST(G3) 5 for all vertices(u, v) // u and v are vertices are one vertices pair 6 w=distance(u,v,GM1,GM2,GM3) // takes average of sum distance 7 Add(A, u, v, w) // Add edge of weight w between u and v in a graph A 8 return Algorithm Prim's-MST(A) This would help us in order to understand what the average performance and space consumption by all three methods. It would also tell us how every function is connected to one another and what should be the most optimal way to define variables.
  • 18.
    A5 SP4. The approachwould be like that of Average-MST We take Shortest Path between all vertices of the three graphs. Then we find the distance between two vertices on all those graphs, take there average and form an edge between those vertices with weight of that edge being the average calculated earlier. We do this for every vertices pair. The resultant structure would be a completely connected graph. We take the shortest path of this graph and that would be the result. 1 Average SSSP(G1,G2,G3): 2 GM1= Algorithm Dijkstra-SP(G1) 3 GM2= Algorithm Dijkstra-SP(G2) 4 GM3= Algorithm Dijkstra-SP(G3) 5 for all vertices(u,v) // u and v are vertices are one vertice pair 6 w=distance(u,v,GM1,GM2,GM3) // takes average of sum distance 7 Add(A,u,v,w) // Add edge of weight w between u and v in a graph A 8 return Algorithm Dijkstra-SP(A)
  • 19.
  • 20.
    A6 • NP1) Calculateprobability of each edge. • NP2) Not reducible to TSP or any other NPC. Because the NP1 is a simple problem that can be solved by calculating probability (for this we need to traverse back to the same node, which is not allowed in TSP), whereas NPCs are NP hard problems.
  • 21.
  • 22.
    A7 AKS1 • The keyidea of AKS primality test is to find the coefficient of xi in ((x+a)n - (xn + a)). If all coefficients are multiple of n, then n is prime else composite number. • To get internal elements, remove first and last elements of each row in a Pascal triangle. For a nth row of a Pascal triangle, the internal element are the coefficients of above equation with a = -1, then the equation ((x-1)n - (xn -1)) AKS2 For N=19 • ((x-1)19- (x19 -1)) = -19x18 + 171x17 - 969x16 + 3876x15 - 11628x14 + 27132x13 - 50388x12 + 75582x11 - 92378x10 + 92378x9 - 75582x8 + 50388x7 - 27132x6 + 11628x5 - 3876x4 + 969x3 - 171x2 + 19x. • The coefficient of equation or the internal elements of Pascal triangle row: 1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1 • Here, each the coefficient or the internal element is the multiple of 19. Therefore, 19 is a prime number as per AKS.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.