Skip to content

Add VertexDataGraph and EdgeDataGraph as concrete subtypes of AbstractVertexOrEdgeDataGraph#121

Open
jack-dunham wants to merge 7 commits into
mainfrom
jd/vertex-edge-datagraph
Open

Add VertexDataGraph and EdgeDataGraph as concrete subtypes of AbstractVertexOrEdgeDataGraph#121
jack-dunham wants to merge 7 commits into
mainfrom
jd/vertex-edge-datagraph

Conversation

@jack-dunham
Copy link
Copy Markdown
Contributor

This point of this abstract interface is to allow the partial implementation of the Dictionaries.jl interface, on these graph types.

  1. Adds VertexDataGraph and EdgeDataGraph as concrete subtypes of AbstractVertexOrEdgeDataGraph
  2. Also adds AbstractVertexDataGraph and AbstractEdgeDataGraph interfaces.
  3. New interface functions insert_edge_data and insert_vertex_data that should be overloaded if a given graph isinsertable.

A subtype of AbstractVertexOrEdgeDataGraph implements a stricter indexing interface, inline with the one used by Dictionaries.jl, that is setindex! strictly sets existing indices (doesn't add a vertex/edge that isn't already in the graph). One should use insert! to strictly add a new vertex/edge with data, and set! to perform an upsert (previous behavior of setindex!.

Eventually, this interface will be applied to AbstractDataGraph, but to avoid breaking changes this is deferred until a later date.

Subtleties

There is at least one subtlety to the above: The function copyto! performs a series of setindex! operations in the case of AbstractVertexDataGraph, i.e. the copied vertices must exist in the destination graph, whereas for AbstractEdgeDataGraph, copyto! "upserts" the data, adding the required edges in if they don't exist already. This is in analogy to SparseArrays:

In [36]: rn = sprand(4,4,0.25)
Out[36]: 4×4 SparseMatrixCSC{Float64, Int64} with 5 stored entries:
 0.859026  0.421836      0.719378
                         
          0.105066        
          0.181513        

In [37]: rn_dst = similar(rn, axes(rn))
Out[37]: 4×4 SparseMatrixCSC{Float64, Int64} with 0 stored entries:
               
               
               
               

In [38]: copyto!(rn_dst, rn)
Out[38]: 4×4 SparseMatrixCSC{Float64, Int64} with 5 stored entries:
 0.859026  0.421836      0.719378
                         
          0.105066        
          0.181513        

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 51.56250% with 124 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.45%. Comparing base (69a86af) to head (f704028).

Files with missing lines Patch % Lines
src/abstractedgeorvertexdatagraph.jl 26.66% 99 Missing ⚠️
src/abstractdatagraph.jl 25.00% 9 Missing ⚠️
src/edgedatagraph.jl 86.20% 8 Missing ⚠️
src/vertexdatagraph.jl 84.31% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
- Coverage   59.89%   57.45%   -2.44%     
==========================================
  Files          10       13       +3     
  Lines         566      818     +252     
==========================================
+ Hits          339      470     +131     
- Misses        227      348     +121     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant