Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

“Everything is a graph”

This is sort of an odd thing to want. You need a diversity of data structures. And BTW the acronym not withstanding, lisp represents graphs not lists.



Under the hood, almost every data structure is a graph.

Linked lists, trees, and heaps are all just graphs with certain requirements about their structure.

Everything else can be represented as a graph, just not as elegantly.

Also as a data point, I really really wish there was an everything is a graph language. I work in graphs all day (in the private industry) and I have to keep modeling them as arrays. It's a pain.


I'm a little late to the party, but humbly submit my thoughts/design from a while back for your review/feedback: https://github.com/vinodkd/halo/blob/master/doc/UserGuide.md...

Edit: I've posted this same comment in multiple places in this conversation to get feedback from specific commenters, not as spam (it's a old personal project)


How so? The cons data structure only points to a single object. You could do singly-linked lists and trees (only with kids pointing to parent) and that's about it, right? And I guess simple loops?


The cons is a directed edge.


To have a graph, in general, you have to have multiple directed edges from a given object. A cons does not offer this, and the best you could do would be to treat cons cells in a extremely convoluted way as binary hypergraph nodes.

You said: "lisp represents graphs not lists". I think you meant that Lisp's defining data structure, based on the cons, was for general graphs, not lists. But that is not really true. If what you meant was "Lisp isn't just restricted to linked lists", sure, but that's true of every programming language with object arrays. So what?


Well, that's part of my point. However, in Lisp you get to macro the language into whatever you like, so you can make lisp into the desired graph language, layered on CONSs, but not so much with other languages because only in Lisp do you get to create an entirely new language. (People think of Lisp wrongly as a programming language, whereas it's really a meta-programming language.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: