i am having great difficulty on one of my assignments. AM I NOT ASKING FOR THE CODE, I AM JUST ASKING FOR SOMEONE TO POINT ME IN THE RIGHT DIRECTION SO I CAN DO SOME RESEARCH AND DO IT MYSELF. The specifiaction says " Different locations will be respresented by a adjancey list representation of a graph, each node should represent a seperate locations, with edges representing links (e.g. doorways) to adjacent locations. you should be able to move between locations and add/ remove locations"
i have designed the GUI, but i have no idea how to start the rest.
A location class is also needed
thank you
Here is my code so far:
using System;
using System.Collections.Generic;
using System.Text;
namespace ASSIGNMENT
{
public class GraphNode<T>
{
private T id;
private LinkedList<T> adjList;
public GraphNode(T id)
{
this.id = id;
adjList=new LinkedList<T>();
}
//add edge from this node, unweighted graph
public void AddEdge(GraphNode<T> to)
{ //add the id of to, to this nodes’ adjacency list
}
public T ID
{
}
public LinkedList<T> GetAdjList()
{
return adjList;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ASSIGNMENT
{
public class Graph<T> where T : IComparable
{
private LinkedList<GraphNode<T>> nodes;
public Graph()
{
nodes = new LinkedList<GraphNode<T>>();
}
public bool IsEmptyGraph()
{
}
public bool ContainsGraph(GraphNode<T> node)
{
//search based on ID – incomplete!
if (n.ID.CompareTo(node.ID) == 0)
return true;
}
public bool IsAdjacent(GraphNode<T> from, GraphNode<T> to)
{
//find from in graph and search its adjList for to
}
public void AddNode(T id)
{
}
public GraphNode<T> GetNodeByID(T id)
{
}
public void AddEdge(T from, T to)
{
}
public void DepthFirstTraverse(T startID, ref List<T> visited)
//perform a DFS traversal starting at startID, leaving a list //of visitied ID’s in the visited list.
{
List<T> adj;
Stack<T> toVisit = new Stack<T>();
GraphNode<T> current;
toVisit.Push(startID);
while (toVisit.Count != 0)
{
//get current node and add unique adjacent nodes to
//toVisit
}
}
public void BreadthFirstTraverse(T startID, ref List<T> visited)
//perform a DFS traversal starting at startID, leaving a list //of visitied ID’s in the visited list.
{
List<T> adj;
Queue<T> toVisit = new Queue<T>();
GraphNode<T> current;
toVisit.Enqueue(startID);
while (toVisit.Count != 0)
{
//get current node and add unique adjacent nodes to
//toVisit
}
}
}
}