JuliaGraphs / JuliaGraphs/Graphs.jl

add `line_graph` (vertex-edge-dual)

Open
#426 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
538
Forks
128
Avg merge
10h 25m
Merged PRs (30d)
2

Description

Hey, thank you for all your awesome work on graphs! : )

I have a request: could you add to operators the function line_graph?

Could be something as simple as:

function line_graph(g::SimpleGraph)
    edge_list = collect(edges(g))
    n_edges = length(edge_list)
    lg = SimpleGraph(n_edges)

    for i = 1:n_edges-1
        ei = edge_list[i]
        for j = i+1:n_edges
            ej = edge_list[j]
            if !isempty(intersect((src(ei), dst(ei)), (src(ej), dst(ej))))
                add_edge!(lg, i, j)
            end
        end
    end

    return lg
end

Contributor guide

Open the contributing guide

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 with the operators documentation entry point and the existing graph-operator APIs, then inspect how SimpleGraph, edges, and related behavior are tested. Use the proposed line_graph example as the starting specification; done means the vertex-edge-dual function is available under operators and its behavior is covered by tests and documentation.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.