24 package org.lightjason.agentspeak.action.builtin;
26 import cern.colt.matrix.tdouble.impl.DenseDoubleMatrix2D;
27 import com.codepoetics.protonpack.StreamUtils;
28 import edu.uci.ics.jung.graph.DirectedSparseGraph;
29 import edu.uci.ics.jung.graph.DirectedSparseMultigraph;
30 import edu.uci.ics.jung.graph.Graph;
31 import edu.uci.ics.jung.graph.SparseGraph;
32 import edu.uci.ics.jung.graph.SparseMultigraph;
33 import edu.uci.ics.jung.graph.UndirectedSparseGraph;
34 import org.junit.Assert;
35 import org.junit.Test;
98 import java.util.ArrayList;
99 import java.util.Collections;
100 import java.util.HashMap;
101 import java.util.List;
102 import java.util.Map;
103 import java.util.stream.Collectors;
104 import java.util.stream.IntStream;
105 import java.util.stream.Stream;
120 final List<ITerm> l_return =
new ArrayList<>();
124 Stream.of(
"sparse",
"SPARSEMULTI",
"DIRECTEDSPARSE",
"DIRECTEDSPARSEMULTI",
"UNDIRECTEDSPARSE",
"UNDIRECTEDSPARSEMULTI" )
126 .collect( Collectors.toList() ),
130 Assert.assertEquals( l_return.size(), 6 );
131 Assert.assertTrue( l_return.stream().map(
ITerm::raw ).allMatch( i -> i instanceof Graph<?, ?> ) );
141 final Graph<?, ?> l_graph1 =
new SparseGraph<>();
142 final Graph<?, ?> l_graph2 =
new SparseGraph<>();
144 IntStream.range( 0, 5 )
149 Stream.of( i, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
150 Collections.emptyList()
153 Assert.assertArrayEquals( l_graph1.getVertices().toArray(), IntStream.range( 0, 5 ).boxed().toArray() );
154 Assert.assertArrayEquals( l_graph2.getVertices().toArray(), IntStream.range( 0, 5 ).boxed().toArray() );
164 final Graph<?, ?> l_graph =
new SparseGraph<>();
168 Stream.of( l_graph,
"x",
"y",
"z" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
169 Collections.emptyList()
172 Assert.assertArrayEquals( l_graph.getVertices().toArray(), Stream.of(
"x",
"y",
"z" ).toArray() );
183 final Graph<Integer, String> l_graph =
new SparseGraph<>();
187 Stream.of(
"xy", 1, 2, l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
188 Collections.emptyList()
193 Stream.of(
"bar", 4, 5, l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
194 Collections.emptyList()
197 Assert.assertEquals( l_graph.getEdgeCount(), 2 );
198 Assert.assertEquals( (
long) l_graph.getEndpoints(
"xy" ).getFirst(), 1 );
199 Assert.assertEquals( (
long) l_graph.getEndpoints(
"xy" ).getSecond(), 2 );
200 Assert.assertEquals( (
long) l_graph.getEndpoints(
"bar" ).getFirst(), 4 );
201 Assert.assertEquals( (
long) l_graph.getEndpoints(
"bar" ).getSecond(), 5 );
211 final Graph<Integer, String> l_graph =
new SparseGraph<>();
215 Stream.of( l_graph,
"foo", 1, 1,
"bar", 1, 2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
216 Collections.emptyList()
219 Assert.assertArrayEquals( l_graph.getEdges().toArray(), Stream.of(
"bar",
"foo" ).toArray() );
230 final List<ITerm> l_return =
new ArrayList<>();
231 final Graph<Integer, String> l_graph =
new SparseGraph<>();
233 IntStream.range( 0, 5 )
235 .forEach( l_graph::addVertex );
239 Stream.of( l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
243 Assert.assertEquals( l_return.size(), 1 );
244 Assert.assertEquals( l_return.get( 0 ).<Number>raw(), (double) l_graph.getVertexCount() );
254 final List<ITerm> l_return =
new ArrayList<>();
255 final Graph<Integer, String> l_graph =
new SparseGraph<>();
257 l_graph.addEdge(
"a", 0, 1 );
258 l_graph.addEdge(
"b", 0, 2 );
259 l_graph.addEdge(
"c", 1, 3 );
260 l_graph.addEdge(
"d", 3, 4 );
265 Stream.of( l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
269 Assert.assertEquals( l_return.size(), 1 );
270 Assert.assertEquals( l_return.get( 0 ).<Number>raw(), 4D );
280 final List<ITerm> l_return =
new ArrayList<>();
281 final Graph<Integer, String> l_graph =
new SparseGraph<>();
283 IntStream.range( 0, 5 )
285 .forEach( l_graph::addVertex );
289 Stream.of( l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
293 Assert.assertEquals( l_return.size(), 1 );
294 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), IntStream.range( 0, 5 ).boxed().toArray() );
304 final List<ITerm> l_return =
new ArrayList<>();
305 final Graph<Integer, String> l_graph =
new SparseGraph<>();
307 l_graph.addEdge(
"a", 0, 1 );
308 l_graph.addEdge(
"b", 0, 2 );
309 l_graph.addEdge(
"c", 1, 3 );
310 l_graph.addEdge(
"d", 3, 4 );
314 Stream.of( l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
318 Assert.assertEquals( l_return.size(), 1 );
319 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"a",
"b",
"c",
"d" ).toArray() );
329 final List<ITerm> l_return =
new ArrayList<>();
330 final Graph<Integer, String> l_graph =
new UndirectedSparseGraph<>();
332 l_graph.addEdge(
"x", 1, 1 );
333 l_graph.addEdge(
"y", 1, 2 );
334 l_graph.addEdge(
"z", 1, 5 );
336 l_graph.addEdge(
"xx", 2, 3 );
337 l_graph.addEdge(
"yy", 2, 5 );
339 l_graph.addEdge(
"xxx", 3, 4 );
341 l_graph.addEdge(
"xxxx", 4, 5 );
342 l_graph.addEdge(
"yyyy", 4, 6 );
347 Stream.of( 1, l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
352 Assert.assertEquals( l_return.size(), 2 );
353 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 1, 2, 3, 4, 5, 6 ).toArray() );
354 Assert.assertEquals( l_return.get( 0 ).raw(),
new DenseDoubleMatrix2D(
new double[][]{
355 {2, 1, 0, 0, 1, 0}, {1, 0, 1, 0, 1, 0}, {0, 1, 0, 1, 0, 0},
356 {0, 0, 1, 0, 1, 1}, {1, 1, 0, 1, 0, 0}, {0, 0, 0, 1, 0, 0}
367 final List<ITerm> l_return =
new ArrayList<>();
368 final Graph<Integer, String> l_graph1 =
new SparseGraph<>();
369 final Graph<Integer, String> l_graph2 =
new SparseGraph<>();
371 l_graph1.addEdge(
"ooo", 1, 2 );
372 l_graph1.addEdge(
"xxx", 1, 2 );
373 l_graph1.addEdge(
"yyy", 2, 3 );
375 l_graph2.addEdge(
"yyx", 1, 2 );
376 l_graph2.addEdge(
"aaa", 2, 3 );
381 Stream.of(
"yyy", l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
385 Assert.assertEquals( l_return.size(), 2 );
386 Assert.assertTrue( l_return.get( 0 ).<Boolean>raw() );
387 Assert.assertFalse( l_return.get( 1 ).<Boolean>raw() );
397 final List<ITerm> l_return =
new ArrayList<>();
398 final Graph<Integer, String> l_graph1 =
new SparseGraph<>();
399 final Graph<Integer, String> l_graph2 =
new SparseGraph<>();
401 IntStream.range( 1, 5 )
403 .forEach( l_graph1::addVertex );
405 IntStream.range( 5, 10 )
407 .forEach( l_graph2::addVertex );
411 Stream.of( 5, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
415 Assert.assertEquals( l_return.size(), 2 );
416 Assert.assertFalse( l_return.get( 0 ).<Boolean>raw() );
417 Assert.assertTrue( l_return.get( 1 ).<Boolean>raw() );
427 final List<ITerm> l_return =
new ArrayList<>();
428 final Graph<Integer, String> l_graph =
new UndirectedSparseGraph<>();
430 l_graph.addEdge(
"a", 1, 1 );
431 l_graph.addEdge(
"b", 1, 2 );
432 l_graph.addEdge(
"c", 1, 5 );
434 l_graph.addEdge(
"d", 2, 3 );
435 l_graph.addEdge(
"e", 2, 5 );
437 l_graph.addEdge(
"f", 3, 4 );
439 l_graph.addEdge(
"g", 4, 5 );
440 l_graph.addEdge(
"h", 4, 6 );
446 Stream.of( l_graph ),
447 IntStream.range( 1, 7 ).boxed()
452 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 3D, 3D, 2D, 3D, 3D, 1D ).toArray() );
462 final List<ITerm> l_return =
new ArrayList<>();
463 final Graph<Integer, String> l_graph1 =
new UndirectedSparseGraph<>();
464 final Graph<Integer, String> l_graph2 =
new UndirectedSparseGraph<>();
466 l_graph1.addEdge(
"x", 1, 1 );
467 l_graph1.addEdge(
"y", 1, 2 );
468 l_graph1.addEdge(
"z", 1, 5 );
470 l_graph2.addEdge(
"x", 1, 1 );
471 l_graph2.addEdge(
"y", 1, 2 );
476 Stream.of( 1, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
480 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 3D, 2D ).toArray() );
490 final List<ITerm> l_return =
new ArrayList<>();
491 final Graph<Integer, String> l_graph =
new UndirectedSparseGraph<>();
493 l_graph.addEdge(
"ma", 1, 2 );
494 l_graph.addEdge(
"na", 2, 3 );
495 l_graph.addEdge(
"oa", 3, 4 );
496 l_graph.addEdge(
"pa", 2, 6 );
500 Stream.of(
"defaultweight", 2, l_graph, 1, 4 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
504 Assert.assertEquals( l_return.size(), 1 );
505 Assert.assertEquals( l_return.get( 0 ).<Number>raw(), 6D );
514 final List<ITerm> l_return =
new ArrayList<>();
515 final Graph<Integer, String> l_graph =
new UndirectedSparseGraph<>();
517 l_graph.addEdge(
"mb", 1, 2 );
518 l_graph.addEdge(
"nb", 2, 3 );
519 l_graph.addEdge(
"ob", 3, 4 );
520 l_graph.addEdge(
"pb", 2, 6 );
524 Stream.of(
"defaultweight", 2, l_graph, 1, 4 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
528 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"mb",
"nb",
"ob" ).toArray() );
538 final List<ITerm> l_return =
new ArrayList<>();
539 final Graph<Integer, String> l_graph =
new UndirectedSparseGraph<>();
541 l_graph.addEdge(
"spanningtreeedge12", 1, 2 );
542 l_graph.addEdge(
"spanningtreeedge26", 2, 6 );
543 l_graph.addEdge(
"spanningtreeedge56", 5, 6 );
544 l_graph.addEdge(
"spanningtreeedge45", 4, 5 );
545 l_graph.addEdge(
"spanningtreeedge34", 3, 4 );
546 l_graph.addEdge(
"spanningtreeedge35", 3, 5 );
547 l_graph.addEdge(
"spanningtreeedge46", 4, 6 );
548 l_graph.addEdge(
"spanningtreeedge24", 2, 4 );
549 l_graph.addEdge(
"spanningtreeedge23", 2, 3 );
550 l_graph.addEdge(
"spanningtreeedge13", 1, 3 );
552 l_graph.addEdge(
"spanningtreeedge28", 2, 8 );
553 l_graph.addEdge(
"spanningtreeedge78", 7, 8 );
554 l_graph.addEdge(
"spanningtreeedge67", 6, 7 );
555 l_graph.addEdge(
"spanningtreeedge68", 6, 8 );
557 l_graph.addEdge(
"spanningtreeedge89", 8, 9 );
558 l_graph.addEdge(
"spanningtreeedge910", 9, 10 );
559 l_graph.addEdge(
"spanningtreeedge710", 7, 10 );
560 l_graph.addEdge(
"spanningtreeedge79", 7, 9 );
562 l_graph.addEdge(
"spanningtreeedge110", 1, 10 );
563 l_graph.addEdge(
"spanningtreeedge19", 1, 9 );
564 l_graph.addEdge(
"spanningtreeedge29", 2, 9 );
566 Assert.assertEquals( l_graph.getEdgeCount(), 21 );
567 Assert.assertEquals( l_graph.getVertexCount(), 10 );
571 Stream.of( l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
575 Assert.assertArrayEquals(
576 l_return.get( 0 ).<Graph<Integer, String>>raw().getEdges().toArray(),
577 Stream.of(
"spanningtreeedge19",
"spanningtreeedge710",
"spanningtreeedge68",
"spanningtreeedge46",
"spanningtreeedge24",
"spanningtreeedge89",
578 "spanningtreeedge45",
"spanningtreeedge23",
"spanningtreeedge67" ).toArray()
582 final Map<Object, Object> l_weight =
new HashMap<>();
583 StreamUtils.windowed(
585 "spanningtreeedge13", 18,
586 "spanningtreeedge23", 10,
587 "spanningtreeedge34", 3,
588 "spanningtreeedge35", 4,
589 "spanningtreeedge24", 9,
590 "spanningtreeedge46", 5,
591 "spanningtreeedge45", 1,
592 "spanningtreeedge56", 4,
593 "spanningtreeedge26", 7,
594 "spanningtreeedge68", 9,
595 "spanningtreeedge67", 9,
596 "spanningtreeedge28", 8,
597 "spanningtreeedge78", 2,
598 "spanningtreeedge79", 4,
599 "spanningtreeedge710", 6,
600 "spanningtreeedge89", 2,
601 "spanningtreeedge910", 3,
602 "spanningtreeedge110", 9,
603 "spanningtreeedge19", 9,
604 "spanningtreeedge29", 9,
605 "spanningtreeedge12", 8
609 ).forEach( i -> l_weight.put( i.get( 0 ), i.get( 1 ) ) );
613 Stream.of( l_weight, l_graph ).map(
CRawTerm::from ).collect( Collectors.toList() ),
617 Assert.assertArrayEquals(
618 l_return.get( 1 ).<Graph<Integer, String>>raw().getEdges().toArray(),
619 Stream.of(
"spanningtreeedge910",
"spanningtreeedge12",
"spanningtreeedge56",
"spanningtreeedge45",
"spanningtreeedge34",
"spanningtreeedge89",
620 "spanningtreeedge78",
"spanningtreeedge26",
"spanningtreeedge28" ).toArray()
631 final List<ITerm> l_return =
new ArrayList<>();
632 final Graph<Integer, String> l_graph1 =
new UndirectedSparseGraph<>();
633 final Graph<Integer, String> l_graph2 =
new UndirectedSparseGraph<>();
635 l_graph1.addEdge(
"search", 1, 2 );
636 l_graph1.addEdge(
"notsearch", 1, 2 );
637 l_graph2.addEdge(
"xxx", 1, 2 );
641 Stream.of( 1, 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
645 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of(
"search",
"xxx" ).toArray() );
655 final List<ITerm> l_return =
new ArrayList<>();
656 final Graph<Integer, String> l_graph =
new UndirectedSparseGraph<>();
658 l_graph.addEdge(
"edge12", 1, 2 );
659 l_graph.addEdge(
"edge23", 2, 3 );
660 l_graph.addEdge(
"edge34", 3, 4 );
661 l_graph.addEdge(
"edge13", 1, 3 );
662 l_graph.addEdge(
"edge24", 2, 4 );
666 Stream.of( l_graph, 1, 2, 2, 3, 3, 4 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
670 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of(
"edge12",
"edge23",
"edge34" ).toArray() );
680 final List<ITerm> l_return =
new ArrayList<>();
681 final Graph<Integer, String> l_graph1 =
new SparseMultigraph<>();
682 final Graph<Integer, String> l_graph2 =
new SparseMultigraph<>();
684 l_graph1.addEdge(
"edgeA1", 1, 2 );
685 l_graph1.addEdge(
"edgeAA1", 1, 2 );
686 l_graph2.addEdge(
"edgeA2", 1, 2 );
687 l_graph1.addEdge(
"edgeB1", 2, 3 );
688 l_graph2.addEdge(
"edgeB2", 3, 4 );
692 Stream.of( 1, 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
696 Assert.assertEquals( l_return.size(), 2 );
697 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"edgeAA1",
"edgeA1" ).toArray() );
698 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"edgeA2" ).toArray() );
705 Stream.of( 1, 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
709 Assert.assertEquals( l_return.size(), 2 );
710 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"edgeAA1",
"edgeA1" ).toArray() );
711 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"edgeA2" ).toArray() );
712 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
713 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
723 final List<ITerm> l_return =
new ArrayList<>();
724 final Graph<Integer, String> l_graph =
new SparseMultigraph<>();
726 l_graph.addEdge(
"o", 1, 2 );
727 l_graph.addEdge(
"p", 1, 2 );
728 l_graph.addEdge(
"q", 2, 3 );
729 l_graph.addEdge(
"r", 2, 3 );
730 l_graph.addEdge(
"s", 2, 3 );
734 Stream.of( l_graph, 1, 2, 2, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
738 Assert.assertEquals( l_return.size(), 2 );
739 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"p",
"o" ).toArray() );
740 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"q",
"r",
"s" ).toArray() );
747 Stream.of( l_graph, 1, 2, 2, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
751 Assert.assertEquals( l_return.size(), 2 );
752 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"p",
"o" ).toArray() );
753 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"q",
"r",
"s" ).toArray() );
754 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
755 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
765 final List<ITerm> l_return =
new ArrayList<>();
766 final Graph<Integer, String> l_graph1 =
new UndirectedSparseGraph<>();
767 final Graph<Integer, String> l_graph2 =
new UndirectedSparseGraph<>();
769 l_graph1.addEdge(
"edgeA", 1, 2 );
770 l_graph2.addEdge(
"edgeA", 2, 3 );
774 Stream.of(
"edgeA", l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
778 Assert.assertEquals( l_return.size(), 4 );
779 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 1, 2, 2, 3 ).toArray() );
789 final List<ITerm> l_return =
new ArrayList<>();
790 final Graph<Integer, String> l_graph =
new UndirectedSparseGraph<>();
792 l_graph.addEdge(
"edge1", 1, 2 );
793 l_graph.addEdge(
"edge2", 2, 4 );
794 l_graph.addEdge(
"edge3", 4, 3 );
798 Stream.of( l_graph,
"edge1",
"edge3" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
802 Assert.assertEquals( l_return.size(), 4 );
803 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 1, 2, 4, 3 ).toArray() );
813 final List<ITerm> l_return =
new ArrayList<>();
814 final Graph<Integer, String> l_graph1 =
new SparseGraph<>();
815 final Graph<Integer, String> l_graph2 =
new SparseGraph<>();
817 l_graph1.addEdge(
"i", 1, 2 );
818 l_graph1.addEdge(
"j", 3, 2 );
819 l_graph2.addEdge(
"k", 4, 2 );
820 l_graph2.addEdge(
"l", 6, 2 );
821 l_graph2.addEdge(
"m", 8, 2 );
825 Stream.of( 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
829 Assert.assertEquals( l_return.size(), 2 );
830 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 2D, 3D ).toArray() );
840 final List<ITerm> l_return =
new ArrayList<>();
841 final Graph<Integer, String> l_graph =
new SparseGraph<>();
843 l_graph.addEdge(
"n", 1, 2 );
844 l_graph.addEdge(
"m", 3, 2 );
845 l_graph.addEdge(
"p", 1, 4 );
849 Stream.of( l_graph, 2, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
853 Assert.assertEquals( l_return.size(), 2 );
854 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 2D, 1D ).toArray() );
863 final List<ITerm> l_return =
new ArrayList<>();
864 final Graph<Integer, String> l_graph1 =
new SparseGraph<>();
865 final Graph<Integer, String> l_graph2 =
new SparseGraph<>();
867 l_graph1.addEdge(
"inedgesingle1", 1, 2 );
868 l_graph1.addEdge(
"inedgesingle2", 2, 2 );
869 l_graph2.addEdge(
"inedgesingle3", 1, 2 );
873 Stream.of( 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
877 Assert.assertEquals( l_return.size(), 2 );
878 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"inedgesingle1",
"inedgesingle2" ).toArray() );
879 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"inedgesingle3" ).toArray() );
886 Stream.of( 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
890 Assert.assertEquals( l_return.size(), 2 );
891 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"inedgesingle1",
"inedgesingle2" ).toArray() );
892 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"inedgesingle3" ).toArray() );
893 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
894 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
904 final List<ITerm> l_return =
new ArrayList<>();
905 final Graph<Integer, String> l_graph =
new SparseGraph<>();
907 l_graph.addEdge(
"inedge3", 1, 2 );
908 l_graph.addEdge(
"inedge4", 2, 2 );
909 l_graph.addEdge(
"inedge5", 1, 3 );
913 Stream.of( l_graph, 2, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
917 Assert.assertEquals( l_return.size(), 2 );
918 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"inedge3",
"inedge4" ).toArray() );
919 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"inedge5" ).toArray() );
926 Stream.of( l_graph, 2, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
930 Assert.assertEquals( l_return.size(), 2 );
931 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"inedge3",
"inedge4" ).toArray() );
932 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"inedge5" ).toArray() );
933 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
934 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
944 final List<ITerm> l_return =
new ArrayList<>();
945 final Graph<Integer, String> l_graph1 =
new DirectedSparseGraph<>();
946 final Graph<Integer, String> l_graph2 =
new DirectedSparseGraph<>();
948 l_graph1.addEdge(
"outdegree1", 1, 2 );
949 l_graph1.addEdge(
"outdegree2", 2, 2 );
950 l_graph2.addEdge(
"outdegree3", 1, 2 );
954 Stream.of( 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
958 Assert.assertEquals( l_return.size(), 2 );
959 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 1D, 0D ).toArray() );
969 final List<ITerm> l_return =
new ArrayList<>();
970 final Graph<Integer, String> l_graph =
new DirectedSparseGraph<>();
972 l_graph.addEdge(
"outdegree4", 1, 2 );
973 l_graph.addEdge(
"outdegree5", 2, 2 );
974 l_graph.addEdge(
"outdegree6", 1, 2 );
978 Stream.of( l_graph, 1, 2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
982 Assert.assertEquals( l_return.size(), 2 );
983 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 1D, 1D ).toArray() );
993 final List<ITerm> l_return =
new ArrayList<>();
994 final Graph<Integer, String> l_graph1 =
new SparseGraph<>();
995 final Graph<Integer, String> l_graph2 =
new SparseGraph<>();
997 l_graph1.addEdge(
"incident1", 1, 2 );
998 l_graph2.addEdge(
"incident1", 1, 2 );
1002 Stream.of(
"incident1", l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1006 Assert.assertEquals( l_return.size(), 2 );
1007 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 2D, 2D ).toArray() );
1017 final List<ITerm> l_return =
new ArrayList<>();
1018 final Graph<Integer, String> l_graph =
new SparseGraph<>();
1020 l_graph.addEdge(
"incident1", 1, 2 );
1021 l_graph.addEdge(
"incident2", 1, 2 );
1025 Stream.of( l_graph,
"incident1",
"incident2" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1029 Assert.assertEquals( l_return.size(), 2 );
1030 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 2D, 0D ).toArray() );
1040 final List<ITerm> l_return =
new ArrayList<>();
1041 final Graph<Integer, String> l_graph1 =
new DirectedSparseGraph<>();
1042 final Graph<Integer, String> l_graph2 =
new SparseGraph<>();
1044 l_graph1.addEdge(
"incidentsingleA", 2, 1 );
1045 l_graph2.addEdge(
"incidentsingleA", 1, 2 );
1049 Stream.of(
"incidentsingleA", l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1053 Assert.assertEquals( l_return.size(), 2 );
1054 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of( 2, 1 ).toArray() );
1055 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 1, 2 ).toArray() );
1062 Stream.of(
"incidentsingleA", l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1066 Assert.assertEquals( l_return.size(), 2 );
1067 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of( 2, 1 ).toArray() );
1068 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 1, 2 ).toArray() );
1069 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1070 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1080 final List<ITerm> l_return =
new ArrayList<>();
1081 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1083 l_graph.addEdge(
"incidentA", 2, 1 );
1084 l_graph.addEdge(
"incidentB", 3, 2 );
1085 l_graph.addEdge(
"incidentC", 5, 6 );
1086 l_graph.addEdge(
"incidentD", 7, 6 );
1090 Stream.of( l_graph,
"incidentA",
"incidentB" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1094 Assert.assertEquals( l_return.size(), 2 );
1095 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of( 2, 1 ).toArray() );
1096 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 3, 2 ).toArray() );
1103 Stream.of( l_graph,
"incidentA",
"incidentB" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1107 Assert.assertEquals( l_return.size(), 2 );
1108 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of( 2, 1 ).toArray() );
1109 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 3, 2 ).toArray() );
1110 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1111 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1121 final List<ITerm> l_return =
new ArrayList<>();
1122 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1123 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1125 l_graph1.addEdge(
"successor1", 2, 1 );
1126 l_graph2.addEdge(
"successor2", 1, 2 );
1130 Stream.of( 1, 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1134 Assert.assertArrayEquals(
1135 l_return.stream().map(
ITerm::<Boolean>raw ).toArray(),
1136 Stream.of(
false,
true ).toArray()
1146 final List<ITerm> l_return =
new ArrayList<>();
1147 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1149 l_graph.addEdge(
"successor1", 2, 1 );
1150 l_graph.addEdge(
"successor2", 3, 1 );
1154 Stream.of( l_graph, 1, 2, 3, 1 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1158 Assert.assertArrayEquals(
1159 l_return.stream().map(
ITerm::<Boolean>raw ).toArray(),
1160 Stream.of(
false,
true ).toArray()
1171 final List<ITerm> l_return =
new ArrayList<>();
1172 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1173 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1175 l_graph1.addEdge(
"predecessor1", 2, 1 );
1176 l_graph2.addEdge(
"predecessor2", 1, 2 );
1180 Stream.of( 1, 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1184 Assert.assertArrayEquals(
1185 l_return.stream().map(
ITerm::<Boolean>raw ).toArray(),
1186 Stream.of(
true,
false ).toArray()
1196 final List<ITerm> l_return =
new ArrayList<>();
1197 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1199 l_graph.addEdge(
"predecessor1", 2, 1 );
1200 l_graph.addEdge(
"predecessor2", 3, 1 );
1204 Stream.of( l_graph, 1, 2, 3, 1 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1208 Assert.assertArrayEquals(
1209 l_return.stream().map(
ITerm::<Boolean>raw ).toArray(),
1210 Stream.of(
true,
false ).toArray()
1221 final List<ITerm> l_return =
new ArrayList<>();
1222 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1223 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1225 l_graph1.addEdge(
"neighborcount1", 2, 1 );
1226 l_graph1.addEdge(
"neighborcount2", 3, 1 );
1227 l_graph2.addEdge(
"neighborcount1", 2, 1 );
1228 l_graph2.addEdge(
"neighborcount2", 3, 1 );
1229 l_graph2.addEdge(
"neighborcount3", 4, 1 );
1233 Stream.of( 1, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1237 Assert.assertArrayEquals(
1238 l_return.stream().map(
ITerm::<Number>raw ).map( Number::longValue ).toArray(),
1239 Stream.of( 2L, 3L ).toArray()
1250 final List<ITerm> l_return =
new ArrayList<>();
1251 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1253 l_graph.addEdge(
"neighborcount1", 2, 1 );
1254 l_graph.addEdge(
"neighborcount2", 3, 1 );
1255 l_graph.addEdge(
"neighborcount3", 5, 3 );
1256 l_graph.addEdge(
"neighborcount4", 4, 1 );
1260 Stream.of( l_graph, 1, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1264 Assert.assertArrayEquals(
1265 l_return.stream().map(
ITerm::<Number>raw ).map( Number::longValue ).toArray(),
1266 Stream.of( 3L, 2L ).toArray()
1277 final List<ITerm> l_return =
new ArrayList<>();
1278 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1279 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1281 l_graph1.addEdge(
"isneighbor1", 2, 1 );
1282 l_graph1.addEdge(
"isneighbor2", 3, 1 );
1283 l_graph2.addEdge(
"isneighbor1", 2, 1 );
1284 l_graph2.addEdge(
"isneighbor2", 3, 1 );
1285 l_graph2.addEdge(
"isneighbor3", 4, 1 );
1289 Stream.of( 1, 2, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1293 Assert.assertArrayEquals(
1294 l_return.stream().map(
ITerm::<Boolean>raw ).toArray(),
1295 Stream.of(
true,
true ).toArray()
1306 final List<ITerm> l_return =
new ArrayList<>();
1307 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1309 l_graph.addEdge(
"isneighbor10", 2, 1 );
1310 l_graph.addEdge(
"isneighbor20", 3, 1 );
1311 l_graph.addEdge(
"isneighbor10", 2, 1 );
1312 l_graph.addEdge(
"isneighbor20", 3, 1 );
1313 l_graph.addEdge(
"isneighbor30", 4, 1 );
1317 Stream.of( l_graph, 1, 2, 3, 4, 3, 2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1321 Assert.assertArrayEquals(
1322 l_return.stream().map(
ITerm::<Boolean>raw ).toArray(),
1323 Stream.of(
true,
false,
false ).toArray()
1334 final List<ITerm> l_return =
new ArrayList<>();
1335 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1336 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1338 l_graph1.addEdge(
"isneighbor1", 2, 1 );
1339 l_graph1.addEdge(
"isneighbor2", 3, 1 );
1340 l_graph2.addEdge(
"isneighbor1", 2, 1 );
1341 l_graph2.addEdge(
"isneighbor2", 3, 1 );
1342 l_graph2.addEdge(
"isneighbor3", 4, 1 );
1346 Stream.of( 1, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1350 Assert.assertEquals( l_return.size(), 2 );
1351 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of( 2, 3 ).toArray() );
1352 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 2, 3, 4 ).toArray() );
1359 Stream.of( 1, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1363 Assert.assertEquals( l_return.size(), 2 );
1364 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of( 2, 3 ).toArray() );
1365 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 2, 3, 4 ).toArray() );
1366 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1367 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1377 final List<ITerm> l_return =
new ArrayList<>();
1378 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1380 l_graph.addEdge(
"neighbors1", 2, 1 );
1381 l_graph.addEdge(
"neighbors2", 3, 1 );
1382 l_graph.addEdge(
"neighbors1", 2, 1 );
1383 l_graph.addEdge(
"neighbors2", 3, 1 );
1384 l_graph.addEdge(
"neighbors3", 4, 1 );
1388 Stream.of( l_graph, 1, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1392 Assert.assertEquals( l_return.size(), 2 );
1393 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of( 2, 3, 4 ).toArray() );
1394 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 1 ).toArray() );
1401 Stream.of( l_graph, 1, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1405 Assert.assertEquals( l_return.size(), 2 );
1406 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of( 2, 3, 4 ).toArray() );
1407 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of( 1 ).toArray() );
1408 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1409 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1419 final List<ITerm> l_return =
new ArrayList<>();
1420 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1421 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1423 l_graph1.addEdge(
"isincident1", 2, 1 );
1424 l_graph1.addEdge(
"isincident2", 3, 1 );
1425 l_graph2.addEdge(
"isincident1", 2, 1 );
1426 l_graph2.addEdge(
"isincident2", 3, 1 );
1427 l_graph2.addEdge(
"isincident3", 4, 1 );
1431 Stream.of( 1,
"isincident2", l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1435 Assert.assertArrayEquals(
1436 l_return.stream().map(
ITerm::raw ).toArray(),
1437 Stream.of(
true,
true ).toArray()
1448 final List<ITerm> l_return =
new ArrayList<>();
1449 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1451 l_graph.addEdge(
"isincident10", 2, 1 );
1452 l_graph.addEdge(
"isincident20", 3, 1 );
1453 l_graph.addEdge(
"isincident10", 2, 1 );
1454 l_graph.addEdge(
"isincident20", 3, 1 );
1455 l_graph.addEdge(
"isincident30", 4, 1 );
1459 Stream.of( l_graph, 1,
"isincident10", 2,
"isincident20" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1463 Assert.assertArrayEquals(
1464 l_return.stream().map(
ITerm::raw ).toArray(),
1465 Stream.of(
true,
false ).toArray()
1475 final List<ITerm> l_return =
new ArrayList<>();
1476 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1477 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1479 l_graph1.addEdge(
"opposite", 2, 1 );
1480 l_graph2.addEdge(
"opposite", 3, 1 );
1484 Stream.of( 1,
"opposite", l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1488 Assert.assertEquals( l_return.size(), 2 );
1489 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 2, 3 ).toArray() );
1499 final List<ITerm> l_return =
new ArrayList<>();
1500 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1502 l_graph.addEdge(
"opposite1", 2, 1 );
1503 l_graph.addEdge(
"opposite2", 3, 4 );
1507 Stream.of( l_graph, 1,
"opposite1", 3,
"opposite2" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1511 Assert.assertEquals( l_return.size(), 2 );
1512 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 2, 4 ).toArray() );
1522 final List<ITerm> l_return =
new ArrayList<>();
1523 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1524 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1526 l_graph1.addEdge(
"outedgesingle1", 1, 2 );
1527 l_graph1.addEdge(
"outedgesingle2", 1, 3 );
1528 l_graph2.addEdge(
"outedgesingle3", 1, 4 );
1529 l_graph2.addEdge(
"outedgesingle4", 1, 5 );
1533 Stream.of( 1, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1537 Assert.assertEquals( l_return.size(), 2 );
1538 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"outedgesingle2",
"outedgesingle1" ).toArray() );
1539 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"outedgesingle4",
"outedgesingle3" ).toArray() );
1546 Stream.of( 1, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1550 Assert.assertEquals( l_return.size(), 2 );
1551 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"outedgesingle2",
"outedgesingle1" ).toArray() );
1552 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"outedgesingle4",
"outedgesingle3" ).toArray() );
1553 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1554 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1564 final List<ITerm> l_return =
new ArrayList<>();
1565 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1567 l_graph.addEdge(
"outedgemultiple1", 1, 2 );
1568 l_graph.addEdge(
"outedgemultiple2", 1, 3 );
1569 l_graph.addEdge(
"outedgemultiple3", 2, 4 );
1570 l_graph.addEdge(
"outedgemultiple4", 2, 5 );
1574 Stream.of( l_graph, 1, 2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1578 Assert.assertEquals( l_return.size(), 2 );
1579 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"outedgemultiple2",
"outedgemultiple1" ).toArray() );
1580 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"outedgemultiple4",
"outedgemultiple3" ).toArray() );
1587 Stream.of( l_graph, 1, 2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1591 Assert.assertEquals( l_return.size(), 2 );
1592 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), Stream.of(
"outedgemultiple2",
"outedgemultiple1" ).toArray() );
1593 Assert.assertArrayEquals( l_return.get( 1 ).<List<?>>raw().toArray(), Stream.of(
"outedgemultiple4",
"outedgemultiple3" ).toArray() );
1594 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1595 Assert.assertEquals( l_return.get( 1 ).raw().getClass(), Collections.synchronizedList( Collections.emptyList() ).getClass() );
1605 final List<ITerm> l_return =
new ArrayList<>();
1606 final Graph<Integer, String> l_graph1 =
new DirectedSparseMultigraph<>();
1607 final Graph<Integer, String> l_graph2 =
new DirectedSparseMultigraph<>();
1609 l_graph1.addEdge(
"predecessorcountsingle1", 1, 2 );
1610 l_graph1.addEdge(
"predecessorcountsingle2", 3, 1 );
1611 l_graph2.addEdge(
"predecessorcountsingle3", 2, 1 );
1612 l_graph2.addEdge(
"predecessorcountsingle4", 5, 1 );
1616 Stream.of( 1, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1620 Assert.assertEquals( l_return.size(), 2 );
1621 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 1D, 2D ).toArray() );
1631 final List<ITerm> l_return =
new ArrayList<>();
1632 final Graph<Integer, String> l_graph =
new DirectedSparseMultigraph<>();
1634 l_graph.addEdge(
"predecessorcountmultiple1", 1, 2 );
1635 l_graph.addEdge(
"predecessorcountmultiple2", 1, 3 );
1636 l_graph.addEdge(
"predecessorcountmultiple3", 4, 2 );
1637 l_graph.addEdge(
"predecessorcountmultiple4", 5, 1 );
1641 Stream.of( l_graph, 1, 2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1645 Assert.assertEquals( l_return.size(), 2 );
1646 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 1D, 2D ).toArray() );
1656 final Graph<Integer, String> l_graph =
new DirectedSparseGraph<>();
1658 l_graph.addVertex( 5 );
1659 l_graph.addVertex( 3 );
1660 l_graph.addEdge(
"vertexremovemultiple", 1, 2 );
1664 Stream.of( l_graph, 1, 3, 5 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1665 Collections.emptyList()
1669 Assert.assertEquals( l_graph.getEdgeCount(), 0 );
1670 Assert.assertArrayEquals( l_graph.getVertices().toArray(), Stream.of( 2 ).toArray() );
1680 final Graph<Integer, String> l_graph1 =
new DirectedSparseGraph<>();
1681 final Graph<Integer, String> l_graph2 =
new DirectedSparseGraph<>();
1683 l_graph1.addVertex( 5 );
1684 l_graph1.addVertex( 3 );
1685 l_graph1.addEdge(
"vertexremovesingle", 5, 7 );
1686 l_graph2.addVertex( 5 );
1687 l_graph2.addVertex( 7 );
1688 l_graph2.addEdge(
"vertexremovesingle", 7, 1 );
1692 Stream.of( 5, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1693 Collections.emptyList()
1696 Assert.assertEquals( l_graph1.getEdgeCount(), 0 );
1697 Assert.assertEquals( l_graph2.getEdgeCount(), 1 );
1699 Assert.assertArrayEquals( l_graph1.getVertices().toArray(), Stream.of( 3, 7 ).toArray() );
1700 Assert.assertArrayEquals( l_graph2.getVertices().toArray(), Stream.of( 1, 7 ).toArray() );
1710 final List<ITerm> l_return =
new ArrayList<>();
1712 final Graph<Integer, String> l_graph1 =
new DirectedSparseGraph<>();
1713 final Graph<Integer, String> l_graph2 =
new DirectedSparseGraph<>();
1715 l_graph1.addEdge(
"successorcountsingle1", 1, 5 );
1716 l_graph1.addEdge(
"successorcountsingle2", 1, 7 );
1717 l_graph1.addEdge(
"successorcountsingle3", 1, 3 );
1719 l_graph2.addEdge(
"successorcountsingle4", 1, 2 );
1720 l_graph2.addEdge(
"successorcountsingle5", 1, 9 );
1724 Stream.of( 1, l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1728 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 3D, 2D ).toArray() );
1738 final List<ITerm> l_return =
new ArrayList<>();
1739 final Graph<Integer, String> l_graph =
new DirectedSparseGraph<>();
1741 l_graph.addEdge(
"successorcountmultiple1", 1, 5 );
1742 l_graph.addEdge(
"successorcountmultiple2", 1, 7 );
1743 l_graph.addEdge(
"successorcountmultiple3", 1, 3 );
1744 l_graph.addEdge(
"successorcountmultiple4", 3, 5 );
1748 Stream.of( l_graph, 1, 3 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1752 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of( 3D, 1D ).toArray() );
1762 final Graph<Integer, String> l_graph1 =
new DirectedSparseGraph<>();
1763 final Graph<Integer, String> l_graph2 =
new DirectedSparseGraph<>();
1765 l_graph1.addEdge(
"removeedgesingle1", 1, 5 );
1766 l_graph1.addEdge(
"removeedgesingle2", 1, 7 );
1767 l_graph1.addEdge(
"removeedgesingle3", 1, 3 );
1769 l_graph2.addEdge(
"removeedgesingle1", 1, 2 );
1770 l_graph2.addEdge(
"removeedgesingle5", 1, 9 );
1774 Stream.of(
"removeedgesingle1", l_graph1, l_graph2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1775 Collections.emptyList()
1778 Assert.assertArrayEquals( l_graph1.getEdges().toArray(), Stream.of(
"removeedgesingle2",
"removeedgesingle3" ).toArray() );
1779 Assert.assertArrayEquals( l_graph2.getEdges().toArray(), Stream.of(
"removeedgesingle5" ).toArray() );
1789 final Graph<Integer, String> l_graph =
new DirectedSparseGraph<>();
1791 l_graph.addEdge(
"removeedgesingle1", 1, 5 );
1792 l_graph.addEdge(
"removeedgesingle2", 1, 7 );
1793 l_graph.addEdge(
"removeedgesingle3", 1, 3 );
1794 l_graph.addEdge(
"removeedgesingle4", 5, 3 );
1795 l_graph.addEdge(
"removeedgesingle5", 5, 7 );
1799 Stream.of( l_graph,
"removeedgesingle2",
"removeedgesingle5" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
1800 Collections.emptyList()
1803 Assert.assertArrayEquals( l_graph.getEdges().toArray(), Stream.of(
"removeedgesingle1",
"removeedgesingle4",
"removeedgesingle3" ).toArray() );
final void distancepath()
test distance-path
returns of an edge the vertices from each graph instance.
returns of any edge the vertices from a single graph instance.
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
final void indegreesingle()
test in-degree single
final void edgelistmultiple()
test edgelist multiple
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
check if a graph contains an edge.
returns the number of predecessors of any vertex in a single graph instance.
final void addedgesingle()
test add-edge single
returns the number of vertices.
final void addedgemultiple()
test add-edge multiple
returns the number of successors of a vertex within each graph instance.
final void endpointsingle()
test endpoint single
base test class with helpers
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
returns the number neighbors of each vertices of a single graph instance.
final void removeedgemultiple()
test remove edge multiple
checks if a vertex is successor of another vertex of each graph instance.
checks all vertex tuple, if the first part is a neighbor of the second one of a single graph instance...
final void issuccessorsingle()
test is-successor single
final void neighborscountmultiple()
test neighborscount single
final void findedgemultiple()
test find-edge multiple
IContext EMPTYPLAN
empty context with plan
final void ispredecessormultiple()
test is-predecessor multiple
final void isincidentmultiple()
test is-incident multiple
final void ispredecessorsingle()
test is-predecessor single
final void degreemultiple()
test degree multiple
final void shortestpath()
test shortest-path
returns a list of incident vertices of each edge of a single graph instance.
final void neighborscountsingle()
test neighborscount single
final void vertextremovesingle()
test remove vertex single
calculates the edge list of the shortest path of two vertices within each graph instance.
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
returns the in-degree of a vertex of multiple graph instances.
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
returns the number of predecessors of a vertex in multiple graph instances.
final void successorcountmultiple()
test successor count multiple
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
final void isincidentsingle()
test is-incident single
final void outdegreemultiple()
test out-degree single
returns all vertices of a graph.
final void edgecount()
test edge-count
adds a vertex to the graph.
checks if a vertex and an edge incident for each graph instance.
returns an edge between vertices for each graph instance.
returns the opposit of a vertex and edge of any graph instance.
returns the number of edges.
execution context with local data
returns the number of vertices that are incident to edge of each graph instance.
returns the number of successors of each vertex of a single graph instance.
creates a minimal spanning tree of any graph instance.
final void isneighbormultiple()
test is-neighbor multiple
final void outdegreesingle()
test out-degree single
adds a single edge to the multiple graph.
final void spanningtree()
test spanning-tree action
final void create()
test graph creating
check if a graph contains a vertex.
returns incomming edges of a vertex of each graph instance.
returns the out-degree of a vertex of each graph instance.
final void edges()
test edges
calculates the distance of two vertices within each graph instance.
final void containsvertex()
test contains-vertex
final void incidentverticesmultiple()
test incident-vertices multiple
final void neigborsmultiple()
test neigbors multiple
checks all vertex tuples if the first part the successor of the second on a single graph instance...
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
removes edges from any graph instance.
final void findedgesingle()
test find-edge single
final void oppositemultiple()
test opposite multiple
returns all edges of all vertex tuples for a single graph instance.
final void vertexremovemultiple()
test remove vertex multiple
returns the opposit of each vertex and edge tuple of a single graph instance.
final void incidentcountsingle()
test incident-count single
add multiple edges to a single graph instance.
final void outedgemultiple()
test outedges multiple
checks if a vertex is neighbor of another vertex of each graph instance.
final void outedgessingle()
test outedges single
< T > T raw()
cast to any raw value type
final void addvertexsingle()
test add-vertex single
checks if a vertex and edge tuple is incident for a single graph instance.
final void inedgesmultiple()
test in-edge
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
final void degreesingle()
test degree single
final void adjacencymatrix()
test adjacency matrix
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
returns outgoing edges of a vertex of each graph.
checks all vertex tuples if the first part the predecessor of the second on a single graph instance...
returns the out-degree of each vertex of a single graph instance.
final void issuccesormultiple()
test is-successor multiple
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
final void containsedge()
test contains-edge
returns the neighbors of each vertex of single graph instance.
removes any vertices from a single graph instance.
returns incomming edges of all vertices of a single graph instance.
final void edgelistsingle()
test edgelist single
final void endpointmultiple()
test endpoint multiple
creates from a graph the adjacency matrix.
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
final void addvertexmultiple()
test add-vertex multiple
returns all edges of two vertices of each graph instance.
final void incidentverticessingle()
test incident-vertices single
checks if a vertex is predecessor of another vertex of each graph instance.
removes a vertex from each graph instance.
final void vertexcount()
test vertex-count
returns the vertex degree of multiple graphs.
returns the number of vertices that are incident to each edge of a single graph instance.
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
creates a graph data structure.
final void removeedgesingle()
test remove edge single
final void neigborssingle()
test neigbors single
final void incidentcountmultiple()
test incident-count single
remove an edge from any graph instance.
final void predecessorcountsingle()
test predecessor count single
final void predecessorcountmultiple()
test predecessor count multiple
returns the in-degree of multiple vertices of a single graph instance.
returns multiple vertex degrees of a single graph.
final void oppositesingle()
test opposite single
returns all edges between vertices for a graph instance.
returns the number neighbors of a vertex of each graph instance.
returns outgoing edges of any vertex of a single graph.
final void successorcountsingle()
test successor count single
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
final void vertices()
test vertices
adds multiple vertices to a single graph.
returns for a graph all edges.
term structure for simple datatypes
final void isneighborsingle()
test is-neighbor single
final void indegreemultiple()
test in-degree multiple
returns a list of incident vertices of an edge of each graph instance.
final void inedgessingle()
test in-edge