diff --git a/ngbatis-demo/src/test/java/ye/weicheng/ngbatis/demo/NebulaBasicDaoTests.java b/ngbatis-demo/src/test/java/ye/weicheng/ngbatis/demo/NebulaBasicDaoTests.java index a816315..ff7b1b5 100644 --- a/ngbatis-demo/src/test/java/ye/weicheng/ngbatis/demo/NebulaBasicDaoTests.java +++ b/ngbatis-demo/src/test/java/ye/weicheng/ngbatis/demo/NebulaBasicDaoTests.java @@ -518,6 +518,13 @@ public void shortestPath() { List> ngPaths = repository.shortestPath("吴小极", "刘小洲"); System.out.println(JSON.toJSONString(ngPaths)); } + + @Test + public void shortestOptionalPath() { + List> ngPaths = repository.shortestOptionalPath("吴小极", "刘小洲", + Arrays.asList("like"),"BIDIRECT"); + System.out.println(JSON.toJSONString(ngPaths)); + } // endregion @Test diff --git a/src/main/java/org/nebula/contrib/ngbatis/proxy/NebulaDaoBasic.java b/src/main/java/org/nebula/contrib/ngbatis/proxy/NebulaDaoBasic.java index f77b0a9..6ce045e 100644 --- a/src/main/java/org/nebula/contrib/ngbatis/proxy/NebulaDaoBasic.java +++ b/src/main/java/org/nebula/contrib/ngbatis/proxy/NebulaDaoBasic.java @@ -519,6 +519,25 @@ default List> shortestPath(@Param("srcId") I srcId, @Param("dstId") I return (List>) MapperProxy.invoke(classModel, methodModel, srcId, dstId); } + /** + * 查找指定起始点和目的点之间的最短路径 + * @param srcId 起始点id + * @param dstId 目的点id + * @param edgeTypeList Edge type 列表 + * @param direction REVERSELY表示反向,BIDIRECT表示双向 + * @return 起始点和目的点之间的最短路径 + */ + default List> shortestOptionalPath(@Param("srcId") I srcId,@Param("dstId") I dstId, + @Param("edgeTypeList") List edgeTypeList, + @Param("direction") String direction + ) { + MethodModel methodModel = getMethodModel(); + methodModel.setReturnType(Collection.class); + methodModel.setResultType(NgPath.class); + ClassModel classModel = getClassModel(this.getClass()); + return (List>) MapperProxy.invoke(classModel, methodModel, + srcId, dstId,edgeTypeList,direction); + } // endregion diff --git a/src/main/resources/NebulaDaoBasic.xml b/src/main/resources/NebulaDaoBasic.xml index 3bda8fa..509f68c 100644 --- a/src/main/resources/NebulaDaoBasic.xml +++ b/src/main/resources/NebulaDaoBasic.xml @@ -287,7 +287,7 @@ - DELETE VERTEX ${ ng.join( p0, ", ", "ng.valueFmt" ) } + DELETE VERTEX ${ ng.join( p0, ", ", "ng.valueFmt" ) } @@ -385,6 +385,15 @@ @var dstId = ng.valueFmt( dstId ); FIND SHORTEST PATH FROM ${ srcId } TO ${ dstId } OVER * YIELD path AS p + +