You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement add_vertex and remove_vertex for Dynamic Graphs in AdjacencyMatrix
Description
Currently, the AdjacencyMatrix class in pydatastructs only supports static graphs, as indicated by the NotImplementedError in the add_vertex and remove_vertex methods. This limitation restricts the use of the adjacency matrix representation for dynamic graphs where vertices can be added or removed after the graph is initialized.
Expected Behavior
The add_vertex and remove_vertex methods should be implemented to allow dynamic modification of the graph. Specifically:
add_vertex: This method should add a new vertex to the graph and update the adjacency matrix and edge weights accordingly.
remove_vertex: This method should remove a vertex from the graph, along with all edges connected to it, and update the adjacency matrix and edge weights.
Proposed Solution
add_vertex:
Add the new vertex to the vertices list.
Update the matrix dictionary to include the new vertex as a key with an empty dictionary as its value.
Ensure that the new vertex is added as a column in the adjacency matrix for all existing vertices.
remove_vertex:
Remove the vertex from the vertices list.
Remove the vertex from the matrix dictionary and all its associated edges.
Remove any edge weights involving the vertex from the edge_weights dictionary.
The text was updated successfully, but these errors were encountered:
Implement
add_vertex
andremove_vertex
for Dynamic Graphs inAdjacencyMatrix
Description
Currently, the
AdjacencyMatrix
class inpydatastructs
only supports static graphs, as indicated by theNotImplementedError
in theadd_vertex
andremove_vertex
methods. This limitation restricts the use of the adjacency matrix representation for dynamic graphs where vertices can be added or removed after the graph is initialized.Expected Behavior
The
add_vertex
andremove_vertex
methods should be implemented to allow dynamic modification of the graph. Specifically:add_vertex
: This method should add a new vertex to the graph and update the adjacency matrix and edge weights accordingly.remove_vertex
: This method should remove a vertex from the graph, along with all edges connected to it, and update the adjacency matrix and edge weights.Proposed Solution
add_vertex
:vertices
list.matrix
dictionary to include the new vertex as a key with an empty dictionary as its value.remove_vertex
:vertices
list.matrix
dictionary and all its associated edges.edge_weights
dictionary.The text was updated successfully, but these errors were encountered: