# LightGraphs.jl/Graphs.jl only values from half the cartesian plane is needed

**URL:** <https://discourse.julialang.org/t/lightgraphs-jl-graphs-jl-only-values-from-half-the-cartesian-plane-is-needed/74080>\
**Category:** Graphs\
**Tags:** question, package, lightgraphs\
**Created:** [January 5, 2022, 10:01am UTC](https://discourse.julialang.org/t/lightgraphs-jl-graphs-jl-only-values-from-half-the-cartesian-plane-is-needed/74080 "2022-01-05T10:01:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Post date:** [January 5, 2022, 10:01am UTC](https://discourse.julialang.org/t/lightgraphs-jl-graphs-jl-only-values-from-half-the-cartesian-plane-is-needed/74080/1 "2022-01-05T10:01:52Z")

</div>

Hi, this is a continuation of [finding link distances between species in a food web](https://discourse.julialang.org/t/help-with-lightgraphs-jl/66663). It’s been a few months so I am starting a new topic. I can find distances between species, but when I want to randomly choose a species pair with a link distance of for example 3, LightGraphs gives me four options which are actually 2 options (because the matrix is diagonally mirrored).

The option of species 1 and species 3 is the same as species 3 and species 1. Is there a way to specify I only want pairings from half the matrix, or to state that (1,3) is the same as (3,1)?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/2/02c736fd4381295e997929a8a4e6103fa86f60b7.png)

Example code

```julia
using LightGraphs

foodWeb2 = [0 0 0 0 1;
        0 0 0 1 0;
        0 0 0 1 0;
        0 0 0 0 1;
        0 0 0 0 0]

test_graph = DiGraph(foodWeb2)
test_graph2 = SimpleGraph(test_graph) # LD is link_distance
test_graph2_results = floyd_warshall_shortest_paths(test_graph2)
harvesting_range = findall(x -> 3.0 <= x, test_graph2_results.dists) # gives 4 coordinates, which refer to two species pairings

```

---

<div class="post-metadata">

**Author:** ![etienne\_dg](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@etienne\_dg](https://discourse.julialang.org/u/etienne_dg)\
**Post date:** [January 5, 2022, 10:56am UTC](https://discourse.julialang.org/t/lightgraphs-jl-graphs-jl-only-values-from-half-the-cartesian-plane-is-needed/74080/2 "2022-01-05T10:56:33Z")

</div>

Something along this way ?

```julia
dists = test_graph2_results.dists
harvesting_range = [(i,j) for i in 1:nv(test_graph2) for j in i+1:nv(test_graph2) if dists[i,j] >= 3]

```

---

<div class="post-metadata">

**Author:** ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)\
**Post date:** [January 5, 2022, 11:23am UTC](https://discourse.julialang.org/t/lightgraphs-jl-graphs-jl-only-values-from-half-the-cartesian-plane-is-needed/74080/3 "2022-01-05T11:23:01Z")

</div>

Thank you very much! You are like a LightGraph superstar 💫

---

<div class="post-metadata">

**Author:** ![etienne\_dg](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@etienne\_dg](https://discourse.julialang.org/u/etienne_dg)\
**Post date:** [January 5, 2022, 1:34pm UTC](https://discourse.julialang.org/t/lightgraphs-jl-graphs-jl-only-values-from-half-the-cartesian-plane-is-needed/74080/4 "2022-01-05T13:34:50Z")

</div>

Also, `LightGraphs.jl` is deprecated, you should now use `Graphs.jl`.  
Don’t worry, these are exactly the same library, the code has just been moved from one repository to another. (see [LightGraphs.jl Transition](https://discourse.julialang.org/t/lightgraphs-jl-transition/69526) for more information).
