Skip to content

Old tutorial using Erlang digraph-module directly in Elixir 1.4

Notifications You must be signed in to change notification settings

fnchooft/digraph_simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Digraphs Examples

As I am starting to get extremely interrested in Erlang, Elixir and Phoenix, i started to browse the web, and offcourse, since we are talking about Erlang which is pretty old , but soooo cool we have a bunch of code which has been battle-tested and hardened for many years.

This example show how to use an erlang module.

The example is basically taken from here.

And get this, it was written on: Sunday, November 18, 2007 with the title:

Digraph and your network, too easy

I started the module like this:

mix new digraph
cd digraph
mkdir src
--- copy content from link into servers.erl - See the "Now the code" section.
mix compile

After this you can start iex like this so you get the environment:

iex -S mix

Now we can start playing with the library. These are almost verbatim to what can be read in the blog-post from easyerl.

iex(1)> dag = :digraph.new()
{:digraph, 90132, 94227, 98328, true}

iex(2)> :servers.add(dag, [:karoten,:ultraten,:muloaten])
:ok

iex(3)> :servers.connect(dag, :karoten, [:ultraten, {:muloaten, :http}])
:ok

iex(4)> :servers.links(dag, :karoten)                                   
[{:karoten, :ultraten, []}, {:karoten, :muloaten, :http}]

iex(5)> :digraph.get_path(dag,:karoten, :muloaten)
[:karoten, :muloaten]

This shows how easy it is to use the library.

Installation

If available in Hex, the package can be installed as:

  1. Add digraphs to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:digraphs, "~> 0.1.0"}]
end
```
  1. Ensure digraphs is started before your application:
```elixir
def application do
  [applications: [:digraphs]]
end
```

About

Old tutorial using Erlang digraph-module directly in Elixir 1.4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published