4 import java.io.Serializable;
5 import java.util.ArrayList;
11 * Class representing the application's graph
12 * @author Sébastien Miquée
14 public class Graph implements Serializable
16 private static final long serialVersionUID = 1L;
19 private ArrayList<GTask> graph ;
20 private int nb_dep_total ;
24 * Default constructor.
28 graph = new ArrayList<GTask>() ;
34 * Return the amount of tasks in the graph.
35 * @return The amount of tasks
37 public int getNbGTask()
44 * Add a task into the graph.
45 * @param _t Task to be add
47 public void addGTask( GTask _t )
51 graph.add( _t.getNum(), _t ) ;
52 nb_dep_total += _t.getNbDep() ;
59 * Add a list of tasks into the graph.
60 * @param _lt : Tasks list to be added
62 public void addGTasks( ArrayList<GTask> _lt )
66 for( int i = 0 ; i < _lt.size() ; i++ )
68 graph.add( _lt.get( i ).getNum(), _lt.get( i ) ) ;
69 nb_dep_total += _lt.get( i ).getNbDep() ;
76 * Return the graph in a tasks list form.
77 * @return The tasks list
79 public ArrayList<GTask> getGraph()
86 * Return the average of dependencies of tasks in the graph.
87 * @return The average of dependencies
89 public double getAverageDep()
91 return nb_dep_total / graph.size() ;
96 * Print the graph in a comprehensible text version.
100 System.out.println();
101 System.out.println( "\t=> Composition of interaction graph:\n" ) ;
102 for( int i = 0 ; i < graph.size() ; i++ )
104 System.out.println( "\t\tTask \""+ graph.get(i).getNum() +"\" => " + graph.get(i).printDep() ) ;
107 System.out.println();
111 /** La programmation est un art, respectons ceux qui la pratiquent !! **/