Repository navigation
feat: initial top-level structure of PropertyGraph #613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SemyonSinchenko
merged 13 commits into
graphframes:master
from
SemyonSinchenko:602-property-graphs
Aug 11, 2025
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7f58a84
Initial top-level structure of PropertyGraph
SemyonSinchenko f6ed533
Missing commit
SemyonSinchenko b7667f4
Merge remote-tracking branch 'graphframes/master' into 602-property-g…
SemyonSinchenko d49adea
WIP
SemyonSinchenko 8f03d8f
Merge remote-tracking branch 'graphframes/master' into 602-property-g…
SemyonSinchenko 30dfa4b
updates from comments
SemyonSinchenko 3b8c604
From comments
SemyonSinchenko b7d9076
Drop outdated docstrings for now
SemyonSinchenko 14fd2ba
Add a projection method
SemyonSinchenko 3068a3e
Add tests
SemyonSinchenko 5fbed5e
Merge remote-tracking branch 'graphframes/master' into 602-property-g…
SemyonSinchenko 9d9be21
Merge conflicts and add more methods+tests
SemyonSinchenko ba0fc00
from comments
SemyonSinchenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/scala/org/graphframes/propertygraph/PropertyGraphFrame.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package org.graphframes.propertygraph | ||
|
|
||
| import org.apache.spark.sql.Column | ||
| import org.graphframes.GraphFrame | ||
| import org.graphframes.propertygraph.property.EdgePropertyGroup | ||
| import org.graphframes.propertygraph.property.VertexPropertyGroup | ||
|
|
||
| /** | ||
| * A high-level abstraction for working with property graphs that simplifies interaction with the | ||
| * GraphFrames library. | ||
| * | ||
| * PropertyGraphFrame serves as a logical structure that manages collections of vertex and edge | ||
| * property groups, providing a user-friendly API for graph operations. It handles various | ||
| * internal complexities such as: | ||
| * - ID conversion and collision prevention | ||
| * - Management of directed/undirected graph representations | ||
| * - Handling of weighted/unweighted edges | ||
| * - Data consistency across different property groups | ||
| * | ||
| * The class maintains separate collections for vertex and edge properties, allowing for flexible | ||
| * graph construction while ensuring data integrity. Each property (vertex or edge) handles its | ||
| * data internally, while this class provides a simplified interface for working with the | ||
| * underlying GraphFrame structure. | ||
| * | ||
| * Example usage: | ||
| * {{{ | ||
| * val userVertices = VertexPropertyGroup("users", userDF, "userId") | ||
| * val productVertices = VertexPropertyGroup("products", productDF, "productId") | ||
| * val purchaseEdges = EdgePropertyGroup("purchases", purchaseDF, "userId", "productId") | ||
| * | ||
| * val graph = PropertyGraphFrame( | ||
| * vertexPropertyGroups = Seq(userVertices, productVertices), | ||
| * edgesPropertyGroups = Seq(purchaseEdges) | ||
| * ) | ||
| * }}} | ||
| * | ||
| * @param vertexPropertyGroups | ||
| * Sequence of vertex property groups that define the graph's vertices | ||
| * @param edgesPropertyGroups | ||
| * Sequence of edge property groups that define the graph's edges | ||
| */ | ||
| case class PropertyGraphFrame( | ||
| vertexPropertyGroups: Seq[VertexPropertyGroup], | ||
| edgesPropertyGroups: Seq[EdgePropertyGroup]) { | ||
| lazy private val vertexGroups: Map[String, VertexPropertyGroup] = | ||
| vertexPropertyGroups.map(pg => pg.name -> pg).toMap | ||
| lazy private val edgeGroups: Map[String, EdgePropertyGroup] = | ||
| edgesPropertyGroups.map(pg => pg.name -> pg).toMap | ||
|
|
||
| def toGraphFrame( | ||
| vertexPropertyGroups: Seq[String], | ||
| edgePropertyGroups: Seq[String], | ||
| edgeFilters: Seq[Column], | ||
| vertexFilters: Seq[Column]): GraphFrame = { | ||
| vertexPropertyGroups.foreach(name => | ||
| require(vertexGroups.contains(name), s"Vertex property group $name does not exist")) | ||
| edgePropertyGroups.foreach(name => | ||
| require(edgeGroups.contains(name), s"Edge property group $name does not exist")) | ||
|
|
||
| val vertices = vertexPropertyGroups | ||
| .map(name => vertexGroups(name).getData(vertexFilters)) | ||
| .reduce(_ union _) | ||
|
|
||
| val edges = edgePropertyGroups | ||
| .map(name => edgeGroups(name).getData(edgeFilters)) | ||
| .reduce(_ union _) | ||
|
|
||
| GraphFrame(vertices, edges) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.