11695 - DS_2017fall_HW4   

Description

The target of the homework is to construct an simple undirected graph (No self loops, No multiple edges)

To implement this undirected simple graph, you are asked to implement these 7 functions
addEdge(A, B, C)
add an edge between A & B with weight C, if  A or B doesn't exist in the graph,  create new vertex A or B in this graph too
deleteEdge(A, B)
delete the edge between A & B, if this edge doesn't exist, then do nothing
deleteVertex(A)
delete the vertex A and all edges that connect to A, if A doesn't exist, do nothing
degree(A)
return the degree of vertex A, return 0 if A doesn't exist 
isExistPath(A, B)
return true(bool) if there is at least one path between A & B, else return false(bool), if  A or B doesn't exist in the graph, return false
deleteGraph()
delete all vertices and edges in the graph
number_of_component()
return the number of the components, if this graph doesn't have any vertex, then return 0

isExistCycle()

return true(bool) if there is at least one cycle in any component, else return false(bool)

You must  #include "function.h" in your code

Input

some graph instructions

Output

results that after finishing these instructions

Sample Input  Download

Sample Output  Download

Partial Judge Code

11695.cpp

Partial Judge Header

11695.h

Tags




Discuss