4 import java.io.Serializable;
5 import java.util.ArrayList;
11 * Class representing the interaction graph of an application
12 * @author Sébastien Miquée
14 public class Graph implements Serializable
16 private static final long serialVersionUID = 1L;
19 private ArrayList<GTask> graph ;
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()
46 * Add a task in the interaction graph.
47 * @param t Task to be add
49 public void addGTask( GTask t )
53 graph.add( t.getNum(), t ) ;
54 nb_dep_total += t.getNbDep() ;
61 * Return the graph in a tasks list form.
62 * @return The tasks list
64 public ArrayList<GTask> getGraph()
71 * Return the average of dependencies of tasks in the graph.
72 * @return The average of dependencies
74 public double getAverageDep()
76 return nb_dep_total / nb_task ;
81 * Print the graph in a text version.
86 System.out.println( "\t=> Composition of interaction graph:\n" ) ;
87 for( int i = 0 ; i < nb_task ; i++ )
89 System.out.println( "\t\tTask \""+ graph.get(i).getNum() +"\" => " + graph.get(i).printDep() ) ;
96 /** La programmation est un art, respectons ceux qui la pratiquent !! **/