@Test
  public void testRandom() throws GraphFactoryException {
    Random random = new Random();
    int order = random.nextInt(40) + 1;
    int maxEdge = order * (order - 1);
    int nbEdge = (maxEdge > 0) ? random.nextInt(maxEdge) : 0;
    graph = new AdjencyListDGraph(GraphFactory.createRandomMatrix(order, nbEdge, true));

    assertThat(graph.addNode(), is(order));
    int randomVertex = random.nextInt(order);
    for (Integer succ : graph.getSuccessors(randomVertex)) {
      assertThat(graph.getPredecessors(succ), hasItem(randomVertex));
    }
    assertThat(graph.inverse().inverse().getGraph(), is(graph.getGraph()));
  }
 @Test
 public void testGetPredecessors() throws Exception {
   List<Integer> resultList = graph.getPredecessors(3);
   Integer[] pred = {0, 1, 2};
   List<Integer> expectedList = Arrays.asList(pred);
   assertEquals(expectedList, resultList);
 }
 @Test
 public void testGetSuccessors() throws Exception {
   List<Integer> resultList = graph.getSuccessors(3);
   Integer[] succ = {1, 2, 4};
   List<Integer> expectedList = Arrays.asList(succ);
   assertEquals(expectedList, resultList);
 }
 @Test
 public void testInverse() {
   int[][] resultMatrix = graph.inverse().getGraph();
   int[][] expectedMatrix = {
     {0, 1, 1, 0, 1}, {0, 0, 1, 1, 0}, {1, 1, 0, 1, 1}, {1, 1, 1, 0, 0}, {1, 0, 1, 1, 0}
   };
   assertThat(resultMatrix, is(expectedMatrix));
 }
 @Test
 public void testAddEdge() throws Exception {
   graph.addArc(4, 3);
   assertTrue(graph.isArc(4, 3));
 }
 @Test
 public void testRemoveEdge() throws Exception {
   graph.removeArc(0, 2);
   assertFalse(graph.isArc(0, 2));
 }
 @Test
 public void testIsEdge() throws Exception {
   assertTrue(graph.isArc(0, 2));
   assertFalse(graph.isArc(4, 4));
 }
 @Test
 public void testAddVertex() throws Exception {
   int val = graph.addNode();
   assertEquals(val, 5);
 }