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_task ;
21 private int nb_dep_total ;
25 * Default constructor.
29 graph = new ArrayList<GTask>() ;
36 * Return the amount of tasks in the graph.
37 * @return The amount of tasks
39 public int getNbGTask()
47 * Add a task into the graph.
48 * @param t Task to be add
50 public void addGTask( GTask _t )
54 graph.add( _t.getNum(), _t ) ;
55 nb_dep_total += _t.getNbDep() ;
62 * Add a list of tasks into the graph.
63 * @param _lt : Tasks list to be added
65 public void addGTasks( ArrayList<GTask> _lt )
69 for( int i = 0 ; i < _lt.size() ; i++ )
71 graph.add( _lt.get( i ).getNum(), _lt.get( i ) ) ;
72 nb_dep_total += _lt.get( i ).getNbDep() ;
80 * Return the graph in a tasks list form.
81 * @return The tasks list
83 public ArrayList<GTask> getGraph()
90 * Return the average of dependencies of tasks in the graph.
91 * @return The average of dependencies
93 public double getAverageDep()
95 return nb_dep_total / graph.size() ;
100 * Print the graph in a comprehensible text version.
104 System.out.println();
105 System.out.println( "\t=> Composition of interaction graph:\n" ) ;
106 for( int i = 0 ; i < graph.size() ; i++ )
108 System.out.println( "\t\tTask \""+ graph.get(i).getNum() +"\" => " + graph.get(i).printDep() ) ;
111 System.out.println();
115 /** La programmation est un art, respectons ceux qui la pratiquent !! **/