Skip to content

Conversation

@goungoun
Copy link
Contributor

@goungoun goungoun commented Sep 28, 2025

What changes were proposed in this pull request?

This PR implement undirected motif pattern such as (u)-[]-(v), (u)-[e]-(v), and (u)-[e*1..3]-(v).

image
g
.find("(u)-[]-(v)")
.where("u.id == 0")
.select("u.id", "v.id")
+---+---+

| id| id|

+---+---+
|  0|  1|

|  0|  2|

+---+---+


g
.find("(u)-[e]-(v)")
.where("u.id == 0")
.select("u.id", "v.id", "e.src", "e.dst", "e.relationship")
+---+---+---+---+------------+
| id| id|src|dst|relationship|
+---+---+---+---+------------+
|  0|  1|  0|  1|      friend|
|  0|  1|  1|  0|      follow|
|  0|  2|  2|  0|     unknown|
+---+---+---+---+------------+



Why are the changes needed?

Without the feature, user have to write a long query and union them by themselves as a workaround. After the change, the bidirectional pattern (u)-[e]-(v) is converted to two patterns (u)-[e]->(v) and (v)-[e]->(u) internally and union the results.

@goungoun goungoun changed the title feat: add bidirectional edge [WIP] feat: add bidirectional edge Sep 28, 2025
@SemyonSinchenko SemyonSinchenko linked an issue Sep 28, 2025 that may be closed by this pull request
@SemyonSinchenko
Copy link
Collaborator

Does it close #501 too? I'm trying to understand, what is the difference from the technical point of view... Like if we can detect bidirectional edges, we can detect undirected too by symmetrize the graph, can't we?

@goungoun goungoun changed the title [WIP] feat: add bidirectional edge [WIP] feat: add undirected edge Sep 28, 2025
@goungoun
Copy link
Contributor Author

@SemyonSinchenko Thanks for clarification. It is undirected edge. I was trying to include in-bound, out-bound edges.

@goungoun
Copy link
Contributor Author

Bidirectional edge is different concept, it should return (0),(1) only which is not this case. I've changed the word to fix this.

@goungoun goungoun closed this Sep 28, 2025
@goungoun goungoun deleted the bidirectional branch September 28, 2025 18:08
@goungoun goungoun restored the bidirectional branch September 28, 2025 18:10
@goungoun goungoun reopened this Sep 28, 2025
@goungoun
Copy link
Contributor Author

I've changed the title and the code, but cannot change the branch name. It closes the PR. :(

@SemyonSinchenko
Copy link
Collaborator

I've changed the title and the code, but cannot change the branch name. It closes the PR. :(

It is not a problem. I linked the right issue.

@goungoun goungoun changed the title [WIP] feat: add undirected edge feat: add undirected edge Sep 29, 2025
@goungoun goungoun marked this pull request as ready for review September 29, 2025 05:23
@goungoun
Copy link
Contributor Author

goungoun commented Sep 29, 2025

I am not sure whether we need undirected edge for a variable length pattern (u)-[e*1..3]-(v) or not. I've modified the code though, the result as a tabular format is quite confusing. It is due to the column order changes. Half of them starting from the vertex 2, half of them ending with the same vertex.

+---------+---------------+---------+--------------+---------+--------------+---------+---------------+
|        u|            _e1|      _v1|           _e2|      _v2|           _e3|        v|              e|
+---------+---------------+---------+--------------+---------+--------------+---------+---------------+
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{2, c, m}|           NULL|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 0, follow}|{0, a, f}|           NULL|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|     NULL|          NULL|{1, b, m}|           NULL|
|{2, c, m}|           NULL|     NULL|          NULL|     NULL|          NULL|{3, d, f}| {2, 3, follow}|
|{2, c, m}|           NULL|     NULL|          NULL|     NULL|          NULL|{0, a, f}|{2, 0, unknown}|
|{2, c, m}| {1, 0, follow}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{1, b, m}|           NULL|
|{2, c, m}|{2, 0, unknown}|{0, a, f}|{0, 1, friend}|{1, b, m}|{1, 2, friend}|{2, c, m}|           NULL|
|{2, c, m}| {0, 1, friend}|{1, b, m}|{1, 2, friend}|     NULL|          NULL|{0, a, f}|           NULL|
|{2, c, m}|           NULL|     NULL|          NULL|     NULL|          NULL|{1, b, m}| {1, 2, friend}|
+---------+---------------+---------+--------------+---------+--------------+---------+---------------+

@goungoun
Copy link
Contributor Author

Hi @rjurney, I am reaching out to you again as you opened the feature request #501. Is the behavior what you were looking for? The idea is pretty simple, converting into two part (u)-[e]->(v) and (v)-[e]->(u) and then union.

@goungoun goungoun changed the title feat: add undirected edge feat: add undirected edge motif pattern Sep 29, 2025
Copy link
Collaborator

@SemyonSinchenko SemyonSinchenko left a comment

Choose a reason for hiding this comment

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

~LGTM

@SemyonSinchenko
Copy link
Collaborator

@rjurney I want to see this feature in a new release and from my point of view, it is a time to start preparing it. What do you think?

@SemyonSinchenko SemyonSinchenko mentioned this pull request Oct 6, 2025
7 tasks
@SemyonSinchenko
Copy link
Collaborator

I'm merging it now to make it a part of the new release.

@SemyonSinchenko SemyonSinchenko merged commit 127271a into graphframes:main Oct 9, 2025
10 checks passed
@goungoun
Copy link
Contributor Author

goungoun commented Oct 9, 2025

@SemyonSinchenko, what is the timeline for the next release? I hoped I could add informational columns _hop, _pattern, _direction. Can I open a new PR for the update?

goungoun added a commit to goungoun/graphframes that referenced this pull request Oct 9, 2025
@SemyonSinchenko
Copy link
Collaborator

@goungoun I think we can wait. I was hoping to deliver a new release this week, but we can actually postpone it to the beginning of the next one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add undirected edges to network motif finding

2 participants