ITensor / ITensor/DataGraphs.jl

Generalize constructors beyond `Dictionary` for vertex data

Open
#11 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
13
Forks
4
Avg merge
5d 13h
Merged PRs (30d)
2

Description

For example:

julia> DataGraph(grid((4,)), ["X", "Y", "Z", "W"])
ERROR: MethodError: no method matching DataGraph(::SimpleGraph{Int64}, ::Vector{String})
Closest candidates are:
  DataGraph(::AbstractGraph) at ~/.julia/dev/DataGraphs/src/datagraph.jl:117
  DataGraph(::AbstractGraph, ::Dictionary) at ~/.julia/dev/DataGraphs/src/datagraph.jl:117
  DataGraph(::AbstractGraph, ::Dictionary, ::Dictionary) at ~/.julia/dev/DataGraphs/src/datagraph.jl:117
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[29]:1

This could automatically convert to a Dictionary, i.e. get converted internally to:

julia> DataGraph(grid((4,)), Dictionary(["X", "Y", "Z", "W"]))
DataGraph{Int64, String, Any, SimpleGraph{Int64}, Graphs.SimpleGraphs.SimpleEdge{Int64}} with 4 vertices:
Base.OneTo(4)

and 3 edge(s):
Edge 1 => 2
Edge 2 => 3
Edge 3 => 4

with vertex data:
4-element Dictionary{Int64, String}
 1 │ "X"
 2 │ "Y"
 3 │ "Z"
 4 │ "W"

and edge data:
0-element Dictionary{Graphs.SimpleGraphs.SimpleEdge{Int64}, Any}

This would only make sense for vertices with linear indexing.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the DataGraph constructor definitions and reproduce the Vector input failure shown in the issue. Check how Dictionary-backed vertex data is handled, then verify that linearly indexed vertex collections such as the four-element vector are accepted and converted consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.