# LightGraphs -- creation of digraph?

**URL:** <https://discourse.julialang.org/t/lightgraphs-creation-of-digraph/23191>\
**Category:** New to Julia\
**Created:** [April 16, 2019, 7:51am UTC](https://discourse.julialang.org/t/lightgraphs-creation-of-digraph/23191 "2019-04-16T07:51:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [April 16, 2019, 7:51am UTC](https://discourse.julialang.org/t/lightgraphs-creation-of-digraph/23191/1 "2019-04-16T07:51:24Z")

</div>

Three simple/elementary questions for first attempts of using LightGraphs:

1. With `M` a matrix, command `g = DiGraph(M)` produces the graph I’m interested in, but how does LightGraphs know whether `M` is meant to be an adjancency matrix or an incidence matrix?
2. If an adjacency matrix is assumed, what happes if the non-zero elements of `M` are floating point numbers and different from `1.0`? Are they converted to `1` or `1.0`? Or are the numbers preserved and used as, say, some weights?
3. Suppose I want to plot the graph using `gplot()` of `GraphPlot`, and that I have specified different colors for the various nodes using `gplot(g,nodefillc = V)` where `V` is a vector of colors. Is there a separate keyword for specifying the alpha color, valid for all nodes?

Thanks!

---

<div class="post-metadata">

**Author:** ![leethargo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leethargo/32/6004_2.png) [@leethargo](https://discourse.julialang.org/u/leethargo)\
**Post date:** [April 16, 2019, 8:49am UTC](https://discourse.julialang.org/t/lightgraphs-creation-of-digraph/23191/2 "2019-04-16T08:49:07Z")

</div>

Re 1. I think it is always assumed that the matrix is for adjacency.  
Re 2. I guess that the matrix is not actually stored, but only used to fill the adjacency lists of `SimpleDiGraph`.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [April 17, 2019, 9:47am UTC](https://discourse.julialang.org/t/lightgraphs-creation-of-digraph/23191/3 "2019-04-17T09:47:32Z")

</div>

Thanks.  
One thing that is confusing… the documentation talks about `SimpleGraph` and `SimpleDiGraph`, but I’ve seen some examples where they instead use the constructors `Graph` and `DiGraph`. Are the latter synonyms, or names from previous versions of LightGraphs?  
In other words: is it more future proof to use `SimpleDiGraph` than using `DiGraph`?

---

<div class="post-metadata">

**Author:** ![leethargo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leethargo/32/6004_2.png) [@leethargo](https://discourse.julialang.org/u/leethargo)\
**Post date:** [April 17, 2019, 10:22am UTC](https://discourse.julialang.org/t/lightgraphs-creation-of-digraph/23191/4 "2019-04-17T10:22:51Z")

</div>

They are just aliases, so you can use either without problem: [https://github.com/JuliaGraphs/LightGraphs.jl/blob/1c92ad8f8f88a58e04b4a933c0f705b105bbd942/src/LightGraphs.jl#L183-L201](https://github.com/JuliaGraphs/LightGraphs.jl/blob/1c92ad8f8f88a58e04b4a933c0f705b105bbd942/src/LightGraphs.jl#L183-L201)

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [April 17, 2019, 3:40pm UTC](https://discourse.julialang.org/t/lightgraphs-creation-of-digraph/23191/5 "2019-04-17T15:40:31Z")

</div>

Super; thanks!  
A final question… I have tried to use GraphPlot, which is simple to use and in general ok. However, it does not handle self edges well…  
As an example of a much better treatment of self edges, see picture below – taken from Boyd and Vandenberghe’s 2018 Introduction to Applied Linear Algebra.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/b/0b78943fff41dd059ef5f833cbfaab3ec14a9968.jpeg)

- Does any of the plot packages for Graph come close to the quality in the above figure?
- Does any of the packages support LaTeX typesetting of math?
