Comments (6)
Hi Neil,
The behavior you're seeing occurs because the CL-Graph's default is to use undirected edges. So you thought you had the graph
a --> b --> d
---> c --> e
but you really had
a <--> b <--> d
<---> c -<-> e
which has no root and so no sense of depth. If you change your code to look like
(setq g (let ((g (make-container 'graph-container :default-edge-type :directed)))
(loop for v in '(a b c d e) do
(add-vertex g v))
(loop for (v1 . v2) in '((a . b) (a . c) (b . d) (c . e)) do
(add-edge-between-vertexes g v1 v2))
g))
(With the added :default-edge-type), then you'll see what you expected. I'll file an enhancement request to have depth report a warning or error if there are no roots to the graph.
thanks,
from cl-graph.
Good point about directed graphs. However, I still get 0 on this example. If I use (graph->dot g t) the graph is directed, so I'm not sure what's going on. I'm a lisp newbie so perhaps I'm not setting variables properly (I just surrounded your example with a (depth ).
from cl-graph.
Curious. I tried
(depth (setq g (let ((g (make-container 'graph-container :default-edge-type :directed)))
(loop for v in '(a b c d e) do
(add-vertex g v))
(loop for (v1 . v2) in '((a . b) (a . c) (b . d) (c . e)) do
(add-edge-between-vertexes g v1 v2))
g)))
and got 2.
What does (graph-roots g) return (it should be the list of the vertex "a").
from cl-graph.
It returns
(#<D> #<E>)
My quicklisp directory lists the package name as cl-graph-20101006-darcs if that matters.
from cl-graph.
Just updated quicklisp and cl-graph to quicklisp 2011-04-18 and cl-graph-20110418-git and the depth problem has disappeared. Sorry for the confusion.
from cl-graph.
Hi Neil,
Great. I was going to suggest trying to upgrade but you figured it out before I got the chance!
from cl-graph.
Related Issues (10)
- In graph.lisp in-undirected-cycle-p is not correct HOT 4
- Incorrect methods has-parent-p, has-children-p
- Graphviz dot export broken? HOT 2
- asdf-system-connections HOT 1
- assign-level may take exponential time HOT 1
- trying to understand why graph->dot is failing HOT 7
- Configure vertex equality check
- Interest in thread-safe cl-graph? HOT 1
- Failing test : The slot CL-GRAPH:GRAPH-VERTEXES is unbound in the object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cl-graph.