Re: [racket-users] Using the graph library

2016-10-31 Thread Stephen Chang
Hi Lawrence,

Can you  provide some more context? Are you looking to learn about
graphs in general, or specifically about the graph library API.

For the former, any well known algorithms textbook should have a
decent introduction. I used CLRS [1] as a guide when developing the
library.

For the latter, take a look at the example programs included with the
library [2]. If things are still confusing, I'm open to feedback on
which specific components could be improved.

[1]: https://mitpress.mit.edu/books/introduction-algorithms
[2]: https://github.com/stchang/graph/tree/master/graph/tests

On Sat, Oct 29, 2016 at 2:59 PM, Lawrence Bottorff  wrote:
> I see the Racket Generic Graph Library, but I don't know how to use it. Where 
> would one go to learn, tutorial-style" the ins and outs of using this 
> library? I take it this library allows you to "roll your own" graph database? 
> I did notice the HTDP has a section on graph things. Would this help?
>
> LB
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Using the graph library

2016-10-29 Thread Daniel Prager
Starting at the very beginning, you could pick up some material on graph
theory, and work through it, while making use of the graph library.

E.g. Here's an introduction to the absolute basics of Graph Theory:

https://www.youtube.com/watch?v=HmQR8Xy9DeM


And here I've followed along in Racket, figuring out parts of the library
as I go:

#lang racket

(require graph
 math/matrix)

; Define a simple graph
(define g (unweighted-graph/undirected
   '((v1 v2) (v1 v3) (v1 v4) (v4 v5) (v5 v6


; How many vertices are in the graph?
(define (cardinality g)
  (length (get-vertices g)))

(cardinality g)


; How many neighbors does vertex v have?
(define (degree g v)
  (length (get-neighbors g v)))

(degree g 'v1)


; Compute the adjacency list
(define (adjacency-list g)
  (for/list ([v (in-vertices g)])
(list v
  (for/list ([ n (in-neighbors g v)])
n

(adjacency-list g)


; Compute the adjacency matrix
(define (adjacency-matrix g)
  (define card-g (cardinality g))
  (define vertices (for/list ([v (in-vertices g)]) v))
  (build-matrix card-g card-g
(λ (u v)
  (if (has-edge? g (list-ref vertices u) (list-ref vertices
v))
  1 0

(adjacency-matrix g)


; Is the graph actually a tree?
(define (is-tree? g)
  (= (length (get-edges g)); Counts edges twice (in both
directions)
 (* 2 (length (mst-kruskal g)

(is-tree? g)

(define loop (unweighted-graph/undirected '((a b) (a c) (b c
(is-tree? loop)


; Visualize the tree
(displayln (graphviz g))

; Paste output into www.webgraphviz.com to make an image


I hope that's enough to get you started

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Using the graph library

2016-10-29 Thread Lawrence Bottorff
On Saturday, October 29, 2016 at 3:06:18 PM UTC-4, jhemann wrote:
> Stephen's talk at 4th Racketcon (https://www.youtube.com/watch?v=SvYJF5HC19w) 
> gave me a good tutorial-ish introduction. 
> 
> 
> JBH
> 
> 
> On Sat, Oct 29, 2016 at 8:59 PM, Lawrence Bottorff  wrote:
> I see the Racket Generic Graph Library, but I don't know how to use it. Where 
> would one go to learn, tutorial-style" the ins and outs of using this 
> library? I take it this library allows you to "roll your own" graph database? 
> I did notice the HTDP has a section on graph things. Would this help?
> 
> 
> 
> LB
> 
> 
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> 
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users...@googlegroups.com.
> 
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> 
> 
> -- 
> 
> 
> JBH

I would need something lots more basic-beginner than this talk. The Chang talk 
seems to assume a lot of graph knowledge. I'll pick through the Racket doc on 
the graph library, but it would be better for me to see something that starts 
at the very beginning.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Using the graph library

2016-10-29 Thread Jason Hemann
Stephen's talk at 4th Racketcon (https://www.youtube.com/watch?v=SvYJF5HC19w)
gave me a good tutorial-ish introduction.

JBH

On Sat, Oct 29, 2016 at 8:59 PM, Lawrence Bottorff 
wrote:

> I see the Racket Generic Graph Library, but I don't know how to use it.
> Where would one go to learn, tutorial-style" the ins and outs of using this
> library? I take it this library allows you to "roll your own" graph
> database? I did notice the HTDP has a section on graph things. Would this
> help?
>
> LB
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
JBH

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Using the graph library

2016-10-29 Thread Lawrence Bottorff
I see the Racket Generic Graph Library, but I don't know how to use it. Where 
would one go to learn, tutorial-style" the ins and outs of using this library? 
I take it this library allows you to "roll your own" graph database? I did 
notice the HTDP has a section on graph things. Would this help?

LB

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.