Recent comments in /f/programming

hollyhoppet wrote

If you really wanted, you could also record a history of each graph at each step. You could get even more granular and have a history of each graph traversal step as well.

I don't really know if there's a way to model the whole thing as a single graph because you're basically describing with each "x contacts y" a different set of relationships, and thus a different graph.

3

hollyhoppet wrote (edited )

I'd say the best way to model this would be to decouple the entities from the graph from the contact and infection steps. Each step could be an object that holds information on node contact and/or infection.

Iterate through each of the steps (represented in an array perhaps), constructing a new graph with each of the entities as nodes. Each "x contacts y" would represent a vertex in this graph.

Have a bit on each entity object representing whether it's infected that persists across iterations. For each step iteration mentioned above, after constructing the graph for that step, do a graph traversal starting from each node that has been infected at the start of this iteration, infecting each traversed node along the way*. At the end, you'll have a set of nodes that all have infected bits set if they were to have been infected.

*You can optimize this a bit by treating any vertex that points to an already-infected node as not needing to be traversed.

3

emma OP wrote

In the alternate universe where I'm not horribly insecure about my voice, I probably would.

But honestly this is fine. IntelliJ is not light on resources, and I'm only a student for another year, so I had planned on learning a free alternative anyway.

4

hollyhoppet OP wrote

But it is mutable? After doing some research, I've found you can change it just like you can change a commit message using ammend or filter-branch. I guess you could say it's a design oversight that there's no author object spanning commits, but that's an engineering problem that comes with its own headaches, and filter-branch will let you change the commit history alright.

1

musou wrote

wow this was a good article. out of all of them my team definitely has the most of "macgyver debt" because we adopted our language kinda early and wrote a lot of our own solutions to things that there now exist popular libraries for. but across all the jobs i've worked i've definitely seen all of these kinds.

3

musou wrote

i guess i'm on the opposite end of that scale, i kinda wish we didn't use slashes for operators at all. sometimes i get confused by which direction the slash is going.

2