Comments (5)
I can work around this issue by keeping a map of {<vertex-id> <my-id>...}
. But it'll be nice to have that support as part of the graph.
from fabric.
Hiya, thanks for your interest & a good question. Custom vertex IDs are supported, but not exactly as what you're after...
- when you create a new
compute-graph
, you can specify an::id-gen-fn
option. This is a single-arg function (takingnil
or the previous ID) and produces the next vertex ID. By default this is simply a counter, but you could e.g. use this to generate UUIDs as vertex IDs:
(require '[thi.ng.fabric.core :as f])
(defn random-uuid (fn [_] (java.util.UUID/randomUUID)))
(def g (f/compute-graph {::f/id-gen-fn random-uuid}))
This however doesn't directly do what you asked for and I guess this is something which could be refactored (but would have to be supplied at construction time and couldn't be changed afterwards).
- The other solution is to just add a custom a user field to each vertex:
(def VAT (f/add-vertex! g 1.2 {:cell-id :vat-rate}))
Then to obtain that (e.g. inside a collection function, whilst processing the signal map):
(->> sig-id (f/vertex-for-id g) f/state :cell-id)
Does this help?
from fabric.
Thanks a lot for your response.
In the local context, for example inside a collection function, I think approach 2) would definitely work to get a mapping from vertex-id
to :cell-id
as you know the former.
In the longer term, I think I think vspec
could probably be checked if it has a key called :id
(or something) and only use ::next-id
if it is not present.
This would also really help the end user in introspecting the values of the vertices in a large enough graph.
Thanks again.
from fabric.
That's a great idea and I will refactor this asap... would also be faster to acess during processing, but would too need to include a check that the user specified ID is unique during construction. cheers!
from fabric.
Thanks a lot!
from fabric.
Related Issues (6)
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 fabric.