Exemple #1
0
 public Graph(LinkedList<LinkedList<string>> table)
 {
     tohm = new Dictionary<string, LinkedList<GFlight>>();
     foreach (LinkedList<string> row in table)
     {
         GFlight f = new GFlight(row);
         if (tohm.ContainsKey(f.from))
         {
             foreach (GFlight flight in tohm[f.from])
             {
                 flight.addNeighbour(f);
             }
         }
         if (!tohm.ContainsKey(f.to))
         {
             tohm[f.to] = new LinkedList<GFlight>();
         }
         tohm[f.to].AddLast(f);
     }
 }
Exemple #2
0
 public void addNeighbour(GFlight f)
 {
     if (!this.apendable(f)) return;
     neighbours.AddLast(f);
 }
Exemple #3
0
 public bool apendable(GFlight f2)
 {
     if (this.end().CompareTo(f2.at) < 0) return true;
     return false;
 }
Exemple #4
0
 public LinkedList<string> unionFind(GFlight current, Dictionary<string, bool> ci, Dictionary<GFlight, bool> fl)
 {
     LinkedList<string> result = new LinkedList<string>();
     if (!fl.ContainsKey(current))
     {
         if (!ci.ContainsKey(current.to))
         {
             result.AddLast(current.to);
             ci[current.to] = true;
         }
         fl[current] = true;
         foreach (GFlight child in current.neighbours)
         {
             foreach (string s in unionFind(child, ci, fl)) {
                 result.AddLast(s);
             }
         }
     }
     return result;
 }