Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,56 @@ public void testAlgorithmJaccardSimilarity() throws Exception {
.checkSinkResult();
}

@Test
public void testAlgorithmKHopModern() throws Exception {
QueryTester
.build()
.withGraphDefine("/query/modern_graph.sql")
.withQueryPath("/query/gql_algorithm_khop_modern.sql")
.execute()
.checkSinkResult();
}

@Test
public void testAlgorithmClosenessCentralityModern() throws Exception {
QueryTester
.build()
.withGraphDefine("/query/modern_graph.sql")
.withQueryPath("/query/gql_algorithm_closeness_centrality_modern.sql")
.execute()
.checkSinkResult();
}

@Test
public void testAlgorithmLabelPropagationModern() throws Exception {
QueryTester
.build()
.withGraphDefine("/query/modern_graph.sql")
.withQueryPath("/query/gql_algorithm_lpa_modern.sql")
.execute()
.checkSinkResult();
}

@Test
public void testAlgorithmCommonNeighbors002() throws Exception {
QueryTester
.build()
.withGraphDefine("/query/modern_graph.sql")
.withQueryPath("/query/gql_algorithm_common_neighbors_002.sql")
.execute()
.checkSinkResult();
}

@Test
public void testAlgorithmJaccardSimilarity002() throws Exception {
QueryTester
.build()
.withGraphDefine("/query/modern_graph.sql")
.withQueryPath("/query/gql_algorithm_jaccard_similarity_002.sql")
.execute()
.checkSinkResult();
}

@Test
public void testEdgeIterator() throws Exception {
QueryTester
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1,1.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expectation appears to lock in incorrect behavior for a disconnected directed graph. From vertex 1, only vertices 2, 3, 4, and 5 are reachable; vertex 6 is unreachable, and the sum of the finite distances is 1 + 1 + 1 + 2 = 5.

The current implementation counts all five other vertices in the numerator while omitting the unreachable distance from the denominator, which produces 1.0 and allows an unreachable vertex to inflate the centrality score.

Could we first define the intended semantics for disconnected graphs and then update both the implementation and this expectation? For example, Wasserman-Faust normalization would give (4 / 5) * (4 / 5) = 0.64 here, while the classical definition with an infinite distance would give 0.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1,4,0.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1,0
2,1
3,1
4,1
5,2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1,1
2,1
3,1
4,1
5,1
6,1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

CREATE TABLE result_tb (
vid int,
cc double
) WITH (
type='file',
geaflow.dsl.file.path='${target}'
);

USE GRAPH modern;

INSERT INTO result_tb
CALL closeness_centrality(1) YIELD (vid, cc)
RETURN cast (vid as int), cc
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

CREATE TABLE result_tb (
vid int
) WITH (
type='file',
geaflow.dsl.file.path='${target}'
);

USE GRAPH modern;

INSERT INTO result_tb
CALL common_neighbors(4, 6) YIELD (id)
RETURN cast (id as int)
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

CREATE TABLE result_tb (
vertex_a int,
vertex_b int,
jaccard_coefficient double
) WITH (
type='file',
geaflow.dsl.file.path='${target}'
);

USE GRAPH modern;

INSERT INTO result_tb
CALL jaccard_similarity(1, 4) YIELD (vertex_a, vertex_b, jaccard_coefficient)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case currently passes for the wrong reason and does not exercise the known non-adjacent-vertex path.

Because vertices 1 and 4 are directly adjacent, vertex 1 receives vertex 4's type-0 inquiry in iteration 2 and counts it as a common-neighbor confirmation. The actual common neighbor, vertex 3, sends its confirmation during iteration 2, so that message only arrives in iteration 3; however, JaccardSimilarity has no iteration-3 handler.

The incorrect intersection count is also 1, so the implementation happens to return the mathematically correct value 0.2. The existing (1, 3) test has the same adjacent-vertices/one-common-neighbor shape.

Please use a discriminating case such as (4, 6), whose expected result is 1 / 3, and fix the iteration-3 aggregation. If fixing the algorithm is outside this PR's scope, I suggest removing this case and tracking the bug in a separate linked issue.

RETURN cast(vertex_a as int), cast(vertex_b as int), jaccard_coefficient
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

CREATE TABLE result_tb (
vid int,
k_value int
) WITH (
type='file',
geaflow.dsl.file.path='${target}'
);

USE GRAPH modern;

INSERT INTO result_tb
CALL khop(1, 2) YIELD (vid, kValue)
RETURN cast (vid as int), kValue
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

CREATE TABLE result_tb (
vid int,
label varchar
) WITH (
type='file',
geaflow.dsl.file.path='${target}'
);

USE GRAPH modern;

INSERT INTO result_tb
CALL lpa() YIELD (vid, label)
RETURN cast (vid as int), label
;
Loading