Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class ServerGraph { / / 3 marks private class WebServer { public string Name; public List P; . . . } private WebServer [
public class ServerGraph marks private class WebServer public string Name; public List P; private WebServer V; private bool E; private int NumServers; marks Create an empty server graph public ServerGraph marks Return the index of the server with the given name; otherwise return private int FindServerstring name marks Double the capacity of the server graph with the respect to web servers private void DoubleCapacity marks Add a server with the given name and connect it to the other server Return true if successful; otherwise return false public bool AddServerstring name, string other marks Add a webpage to the server with the given name Return true if successful; other return false public bool AddWebPageWebPage w string name marks Remove the server with the given name by assigning its connections and webpages to the other server Return true if successful; otherwise return false public bool RemoveServerstring name, string other marks Add a connection from one server to another Return true if successful; otherwise return false Note that each server is connected to at least one other server public bool AddConnectionstring from, string to marks Return all servers that would disconnect the server graph into two or more disjoint graphs if ever one of them would go down Hint: Use a variation of the depthfirst search public string CriticalServers marks Return the shortest path from one server to another Hint: Use a variation of the breadthfirst search public int ShortestPathstring from, string to marks Print the name and connections of each server as well as the names of the webpages it hosts public void PrintGraph
public class ServerGraph
marks
private class WebServer
public string Name;
public List P;
private WebServer V;
private bool E;
private int NumServers;
marks
Create an empty server graph
public ServerGraph
marks
Return the index of the server with the given name; otherwise return
private int FindServerstring name
marks
Double the capacity of the server graph with the respect to web servers
private void DoubleCapacity
marks
Add a server with the given name and connect it to the other server
Return true if successful; otherwise return false
public bool AddServerstring name, string other
marks
Add a webpage to the server with the given name
Return true if successful; other return false
public bool AddWebPageWebPage w string name
marks
Remove the server with the given name by assigning its connections
and webpages to the other server
Return true if successful; otherwise return false
public bool RemoveServerstring name, string other
marks
Add a connection from one server to another
Return true if successful; otherwise return false
Note that each server is connected to at least one other server
public bool AddConnectionstring from, string to
marks
Return all servers that would disconnect the server graph into
two or more disjoint graphs if ever one of them would go down
Hint: Use a variation of the depthfirst search
public string CriticalServers
marks
Return the shortest path from one server to another
Hint: Use a variation of the breadthfirst search
public int ShortestPathstring from, string to
marks
Print the name and connections of each server as well as
the names of the webpages it hosts
public void PrintGraph
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started