Yomguithereal / gexf

Gexf library for JavaScript
MIT License
34 stars 10 forks source link

Dynamic attributes support #21

Open mars0i opened 10 years ago

mars0i commented 10 years ago

GEXF allows one to specify dynamic attributes: Attributes of a node or edge, with different attribute values during different time periods. I believe that gexf-parser doesn't yet support this functionality, but it could be useful. (My use case: I write agent-based simulations that use neural networks. Within each neural network, nodes' activation values change over time, and weights of links between nodes change over time. Each neural network is embedded in an agent that represents a person. These agents are embedded in a social network, so each agent is a node. Each agent's overall state changes as a result of changes within its neural networks.) Thanks.

Yomguithereal commented 10 years ago

Hello @mars0i,

would it be possible for you to present a sample of the kind of gexf you'd like to be able to parse so I can evaluate the time needed to implement the new features you need in the library?

mars0i commented 10 years ago

Of course! Thank you. Here's one:

https://github.com/mars0i/popco2/blob/master/notes/general/popcoDynamicExample.gexf

In my graphs, the nodes, edges, and attvalue attributes can have timestamps.

Once a node or edge is introduced, it never goes away, so these have a start float but no end or endopen property.

Attributes specified with attvalue have a start float representing a tick (a timestep), and an endopen float representing the end of that tick. Since my attvalue attributes often change on each tick, I don't use longer time intervals for these attributes. GEXF also allows overlapping intervals and date strings, but I don't use them. I think it's supposed to be possible to use integers for times, but I had a problem using integers at one point, and haven't investigated using them recently.

(I tried to make a relatively small example file, but you might want one that's even smaller. I'd be happy to make one with fewer nodes if that would be helpful, but it will require a little more effort.)

Thanks!

mars0i commented 10 years ago

I've been thinking about and experimenting with ways to modify parser.js to allow dynamic attributes. I may not have sufficient understanding of parser.js or of Javascript in general to contribute a solution, but perhaps I can offer helpful suggestions in any event. For example, the following point might be obvious to you, but I just figured it out recently:

It seems clear to me that dynamic attributes will require that attributes be returned to callers in data structures that are incompatible with the current representation of attributes, because attributes have to depend on time intervals. However, returning this more complex data structure should happen if and only if the GEXF file has mode = "dynamic". Thus code that uses the result of the parser and assumes that it's returning the data structures that it presently returns will not break as long as the input file is static. (Note that parser.js correctly sets the mode to static when mode is not set in the GEXF file.) The only code that will break is code that uses a dynamic GEXF file without testing to see if it's dynamic. (Since there are probably few dynamic GEXF files around, this probably won't happen by accident.) Also, if someone wants to use a dynamic GEXF file as if it were static, all they have to do is to replace the mode specifications with "static". This might be a bad idea for a given application, but it will work. (It works now: Running a dynamic GEXF file through parser.js just ignores the time indexing. I think it probably simply uses the last attvalue. For example, gexf3d is able read the output from a dynamic GEXF file run through the gexf parser right now without any trouble, though the parser of coure does not yet preserve the dynamic time-indexing.)

mars0i commented 10 years ago

I've been playing around with trying to implement dynamic attributes. I've come to realize that this is a huge change, and not easy to implement. That's how it looks to me, anyway. So ... for whatever it's worth, my use case just involves (a) integer times (ticks), (b) with intervals that are always one tick long. So all that I need is a single time index for each attribute. That's easier to implement than full dynamic GEXF, but implementing this functionality alone wouldn't go very far toward the general dynamic GEXF.

Yomguithereal commented 10 years ago

Hello @mars0i, Yes, including dynamics is not a small change. Unfortunately I lack time to enhance the library right now, so if you need new features quickly you can use a custom version fitting your needs. I am of course interested of any problem and solutions you'd find in the process.

mars0i commented 10 years ago

I've got something that might work for my particular needs, but I'll have to work on the other end of the process to use it. I'll let you know what happens. Thanks.

apitts commented 10 years ago

@mars0i I'm also very interested in dynamic GEXF and would be very keen to hear about any progress you make on that front.