1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
public class SimpleGraph : GraphUtile
{
private List<RouteCity> tableRoute = new List<RouteCity>();
public SimpleGraph()
: base()
{
tableRoute = GetRoute();
foreach (RouteCity route in tableRoute)
{
this.AddArc(
route.City1,rndPosition.X, rndPosition.Y,rndCode,
route.City2, rndPosition.X, rndPosition.Y, rndCode);
}
}
private List<RouteCity> GetRoute()
{
List<RouteCity> l = new List<RouteCity> {
new RouteCity("ROOT", "Paris"),
new RouteCity("Paris", "Chartres"),
new RouteCity("Chartres", "Le Mans"),
new RouteCity("Le Mans", "Tours"),
new RouteCity("Tours", "Nantes"),
new RouteCity("Paris", "Dijon"),
new RouteCity("Dijon", "Lyon"),
new RouteCity("Paris", "Rouen"),
new RouteCity("Paris", "Arras"),
new RouteCity("Arras", "Lille"),
new RouteCity("Rouen","Arras")
};
// List<RouteCity> l = new List<RouteCity> {
//new RouteCity("ROOT", "Contantine"),
//new RouteCity("Contantine", "Annaba"),
//new RouteCity("Contantine", "Batna"),
//new RouteCity("Contantine", "Setif"),
//new RouteCity("Setif", "Batna"),
//new RouteCity("Setif", "Msila"),
//new RouteCity("Setif", "BBA"),
//new RouteCity("Contantine", "Tebessa"),
//new RouteCity("Guelma", "SoukAhras")
//};
return l;
}
private Random rnd = new Random();
private Point rndPosition
{
get
{
Point p = new Point() { X = rnd.Next(100, 500), Y = rnd.Next(100, 500) };
return p;
}
}
private NodeType rndCode
{
get
{
int n = Enum.GetValues(typeof(NodeType)).Length;
int i=rnd.Next(0,n);
NodeType c =(NodeType)Enum.GetValues(typeof(NodeType)).GetValue(i);
return c;
}
}
} |
Partager