Question: So I need a python code which will traverse a graph and will return the time complexity. We will pick a random attack path from

So I need a python code which will traverse a graph and will return the time
complexity. We will pick a random attack path from root to leaf. Let's say the attack
path will be P1=V1,V2,V3,V4,V5. Now the program will calculate the risk of P 1 and
store it, also it will count the vulnerabilities lying in P1 and will store it. The program
will set P1 as the optimal path, "Popt" and the risk as optimal as well which is "Ropt=
R1." Then, the program will take another attack path which is P 2, and it will select
the next leaf node from the first path. Means, if P 1 is P1=V1,V2,V3,V4,V5 is this
one, then P 2 will be,P2=V1,V2,V3,V4,V6(means the next leaf node of V 5). Now, it
will calculate the risk of P2, store the risk, calculate the number of vulnerabilities in
P2 and store it as well. Now, it will compare the risks of P1 and P2. If R(P2) is greater
than R(P1), it will update the current optimal: Popt -P2 and Ropt R(P2). Else,
take another new path to check with the current optimal but this time, don't take
any nodes from the leaf anymore, move 1 level up, and take path like: V1, V2,V3,V7.
So in this way, the program should continue, and keep checking the whole tree. And
at the end of traversing, the program should be able to return the time complexity,
the attack path with highest risk and the set of associated vulnerabilities in that
path.
So I need a python code which will traverse a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!