Ejemplo n.º 1
0
 /// <summary>
 /// connects node to the provided node
 /// </summary>
 /// <param name="vertex_connection">node to be adjacent to the calling node</param>
 public void AddEdge(CSC382Graph_Vertex <T> vertex_connection)
 {
     if (vertex_connection != this)
     {
         Connected_vertices.AddLast(vertex_connection);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// removes an edge from a connected node
 /// </summary>
 /// <param name="edge_to_remove">edge to remove</param>
 public void RemoveEdge(CSC382Graph_Vertex <T> edge_to_remove)
 {
     if (edge_to_remove != default)
     {
         Connected_vertices.Remove(edge_to_remove);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// checks to see if provided node is connected to the calling node
 /// </summary>
 /// <param name="vertex_to_find">node to search for</param>
 /// <returns></returns>
 public bool VertexConnected(CSC382Graph_Vertex <T> vertex_to_find)
 {
     foreach (CSC382Graph_Vertex <T> i in Connected_vertices)
     {
         if (i == vertex_to_find)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// searches the vertex node to see if the specified edge is connected to it
 /// </summary>
 /// <param name="vertex_to_search_in">vertex node to check connected nodes</param>
 /// <param name="edge_to_check_for">vertex node to look for</param>
 /// <returns></returns>
 public bool IsEdge(CSC382Graph_Vertex <T> vertex_to_search_in, CSC382Graph_Vertex <T> edge_to_check_for)
 {
     return(vertex_to_search_in.VertexConnected(edge_to_check_for));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// add an edge to the graph between the two vertex nodes specified
 /// </summary>
 /// <param name="start_vertex">vertex node to start the edge at</param>
 /// <param name="end_vertex">vertex node to end the edge at/param>
 public void AddEdge(CSC382Graph_Vertex <T> start_vertex, CSC382Graph_Vertex <T> end_vertex)
 {
     start_vertex.AddEdge(end_vertex);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// remove an edge that is between the two vertex nodes specified
 /// </summary>
 /// <param name="start_vertex">starting vertex node that the edge is connected to</param>
 /// <param name="end_vertex">ending vertex node that the edge is connected to</param>
 public void RemoveEdge(CSC382Graph_Vertex <T> start_vertex, CSC382Graph_Vertex <T> end_vertex)
 {
     start_vertex.RemoveEdge(end_vertex);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// remove vertex node that is specified
 /// </summary>
 /// <param name="vertex_to_remove">vertex node that is to be removed from graph</param>
 public void RemoveVertex(CSC382Graph_Vertex <T> vertex_to_remove)
 {
     Graph.Remove(vertex_to_remove);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// remove vertex node that holds the specified data
        /// </summary>
        /// <param name="data">data that is being held in vertex to be removed</param>
        public void RemoveVertex(T data)
        {
            CSC382Graph_Vertex <T> vertex_to_remove = FindVertex(data);

            RemoveVertex(vertex_to_remove);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// inserta a new vertex node into the graph with specified data
        /// </summary>
        /// <param name="data">information to be stored in the vertex node</param>
        /// <returns></returns>
        public CSC382Graph_Vertex <T> Insert(T data)
        {
            CSC382Graph_Vertex <T> new_node = new CSC382Graph_Vertex <T>(data);

            return(Insert(new_node));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// inserts a new vertex onto the graph
 /// </summary>
 /// <param name="vertex">vertex node to be added</param>
 /// <returns></returns>
 public CSC382Graph_Vertex <T> Insert(CSC382Graph_Vertex <T> vertex)
 {
     Graph.AddLast(vertex);
     return(vertex);
 }
Ejemplo n.º 11
0
 /// <summary>
 ///  secondary constructor that makes a new graph with an initial vertex node
 /// </summary>
 /// <param name="initial_vertex">the vertex you want to use at the initial vertex of graph</param>
 public CSC382Graph_NodeBased(CSC382Graph_Vertex <T> initial_vertex)
 {
     Graph = new LinkedList <CSC382Graph_Vertex <T> >();
     Insert(initial_vertex);
 }