Error in Directed Graph Documentation

Issue #3698 resolved
John Mercouris created an issue

If you look in the examples, the documentation mentions that you may setup directed graphs: http://docs.sqlalchemy.org/en/rel_1_0/orm/examples.html#module-examples.graphs

The code for the directed graph can be found here: http://docs.sqlalchemy.org/en/rel_1_0/_modules/examples/graphs/directed_graph.html

Unfortunately the code for the directed graph is actually for an undirected graph (directed vs undirected graph) http://www.differencebetween.com/wp-content/uploads/2011/05/DifferenceBetween_Directed_UnDirected_Graphs1.jpg

The reason it is a directed graph is because you may not add a relationship from n1->n2 as well as from n2->n1. The program will crash and complain that there is a duplicate entry.

For your convenience I have modified the program to show an example of a directed graph: (http://pastebin.com/xJDPdvYJ) - also attached to this issue. Also attached is the database generated from running the file.

You can run the program to demonstrate it for yourself, thank you for your time.

Comments (4)

  1. Mike Bayer repo owner

    it's a directed graph with the constraint that the integer value of a node must also be "higher" or "lower" than that of its neighbor. However, none of this is necessary to perform the task of this example which is to illustrate how to use SQLAlchemy, and it is not worth a semantic argument, so I will change it right now (nodes will become anonymous because the numeral is no longer significant).

  2. Mike Bayer repo owner

    Simplify directed graph example

    Changed the "directed graph" example to no longer consider integer identifiers of nodes as significant; the "higher" / "lower" references now allow mutual edges in both directions.

    Change-Id: Ibfd5b420f0451a6fc746f0bcbbbb062f8f88dc1d Fixes: #3698

    → <<cset c3de4061fd49>>

  3. Mike Bayer repo owner

    Simplify directed graph example

    Changed the "directed graph" example to no longer consider integer identifiers of nodes as significant; the "higher" / "lower" references now allow mutual edges in both directions.

    Change-Id: Ibfd5b420f0451a6fc746f0bcbbbb062f8f88dc1d Fixes: #3698 (cherry picked from commit c3de4061fd490adcd8b75c79685f4a831b869f9e)

    → <<cset 84ba09a7d7b0>>

  4. Log in to comment