Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Languages with native / syntactical / inline graph support?

The graph is arguably the most versatile and valuable data structure of all. I can store single variables, lists, hashes etc., and of course graphs, with it.

Given this, are there any languages that offer inline / native graph support and syntax? I can create variables, arrays, lists and hashes inline in Ruby, Python and Javascript, but if I want a graph, I have to either manage the representation myself with a matrix / list, or select a library, and use the graph through method calls.

Why on earth is this still the case in 2010? And, practically, are there any languages out there which offer inline graph support and syntax?

like image 478
Ollie Glass Avatar asked Jul 22 '10 00:07

Ollie Glass


3 Answers

The main problem of what you are asking is that a more general solution is not the best one for a specific problem. It's just average for all of them but not a best one.

Ok, you can store a list in a graph assuming its degeneracy but why should you do something like that? And how would you store an hashmap inside a graph? Why would you need such a structure?

And do not forgot that graph implementation must be chosen accordingly to which operations you are going to do on it, otherwise it would be like using a hashtable to store a list of values or a list to store an ordered collection instead that a tree. You know that you can use an adjacency matrix, an edge list or adjacency lists.. every different implementation with it's own strenghts and weaknesses.

Then graphs can have really many properties compared to other collections of data, cyclic, acyclic, directed, undirected, bipartite, and so on.. and for any specific case you can implement them in a different way (assuming some hypothesis on the graph you need) so having them in native syntax would be overkill since you would need to configure them anyway (and language should provide many implementations/optimizations).

If everything is already made you remove the fun of developing :) By the way just look for a language that allows you to write your own graph DSL and live with it!

like image 71
Jack Avatar answered Nov 14 '22 16:11

Jack


Gremlin, a graph-based programming language: https://github.com/tinkerpop/gremlin/wiki

like image 2
Ollie Glass Avatar answered Nov 14 '22 18:11

Ollie Glass


GrGen.NET (www.grgen.net) is a programming language for graph transformation plus an environment including a graphical debugger. You can define your graph model, the rewrite rules, and rule control with some nice special purpose languages and use the generated assemblies/C# code from any .NET language you like or from the supplied shell.

To understand why normal languages don't offer such a convenient/built-in interface to graphs, just take a look at the amount of code written for that project: the compiler alone is several man-years of work. That's a price tag too hefty for a feature/data structure only a minority of programmers ever need - so it's not included in general purpose programming languages.

like image 1
user420511 Avatar answered Nov 14 '22 16:11

user420511