feat: graph_from_data_frame(vertex_ids = TRUE) reads numeric vertex IDs, so as_data_frame(what = "both") round-trips unnamed graphs - #2923
Open
schochastics wants to merge 2 commits into
Open
schochastics wants to merge 2 commits into
schochastics wants to merge 2 commits into
Conversation
… IDs, so `as_data_frame(what = "both")` round-trips unnamed graphs Closes #223. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if dde9886 is merged into main:
|
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #223.
Until now,
graph_from_data_frame()always readvertices[, 1]as vertex names and converted the endpoints to strings. That meantas_data_frame(g, what = "both")could not be passed back in for graphs without vertex names. This PR adds an opt-in keyword argument:With
vertex_ids = TRUE:dmust be positive whole numbers. They are used as vertex IDs.verticesbecomes a vertex attribute, one row per vertex in ID order. Nonameattribute is created unlessverticeshas anamecolumn.verticesisNULL, the vertex count is the largest ID ind, so isolated vertices up to that ID are kept.The default (
vertex_ids = FALSE) behaves as before. In addition:dare not listed invertices" error now suggestsvertex_ids = TRUEwhen the endpoints are in-range integers.verticesused to fail with an internal[.data.frameerror. It now reports "verticescontains no columns" with the same hint.as_data_frame()returns exactly this for an unnamed graph without vertex attributes.Notes:
vertex_idsis also added to thenewsignature intools/migrations/conversion.R, and the ARG_HANDLE block was regenerated. As a result, the abbreviationsv,ve,verandvertnow abort as ambiguous. Before, they were recovered asverticeswith a deprecation warning.make_ring()'sname) are not stored in the data frames, so the round trip is exact only for vertex and edge data.🤖 Generated with Claude Code