question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Graphs.transform*

See original GitHub issue

When I’m creating my graph, I don’t know all the nodes/edges, so I use proxies like the ids of the nodes and the ids of the edges while registering the edges and nodes as they come in. Think of this as a stream being parsed where the node 1 says “I’m linked to 2 and 4”, but we haven’t parsed 2 nor 4 already.

When I’m done creating it, I’d like to have a copy of the graph but with the actual nodes and edges. So similarly to all the Maps.transform* methods, I’d like to have Graphs.transform* methods where applicable.

The only alternative I see is to create proxy items before creating the graph, but that’s a heavy burden on the user,

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
jbduncancommented, Oct 8, 2017

(@jrtom I just happened to discover the project when browsing the bazelbuild org page a few days ago (Bazel’s interested me for a while now), and in turn I got curious about the project’s implementation, so I skimmed over its internal files. I just happened to view a particular file, and in the process I found that particular comment.

Kind of a cool coincidence, I’d say. 😃)

0reactions
jrtomcommented, Aug 1, 2018

@Sadgrinner whoops, another good catch. 😃

The most obvious way to deal with that is to just brute-force it, something like (I haven’t checked the code below, just winging it):

static <T> ElementOrder<T> transformedNodeOrder(Graph<?> graph, @Nullable Comparator<T> comparator) {
  switch graph.nodeOrder() {
     case UNORDERED: return ElementOrder.<T>unordered();
     case INSERTION: return ElementOrder.<T>insertion();
     case SORTED: return ElementOrder.<T>sorted(checkNotNull(comparator));
     default: throw new IllegalStateException(...);
}

and then call transformedNodeOrder(originalGraph, comparator) instead of graph.nodeOrder().

I think that should do it. Needless to say, for cases where you don’t have a comparator you should probably overload this method so that you don’t have to supply one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function Transformations - Math is Fun
Just like Transformations in Geometry, we can move and resize the graphs of ... Here are some simple things we can do to...
Read more >
2.5 Using Transformations to Graph Functions
When the graph of a function is changed in appearance and/or location we call it a transformation. There are two types of transformations....
Read more >
Graph Transformations
In this chapter, we'll discuss some ways to draw graphs in these circumstances. Transformations “after” the original function. Suppose you know what the...
Read more >
Transformations of Graphs - Varsity Tutors
A transformation of a graph maps an initial figure, called a preimage, onto a final figure, called an image.
Read more >
Functions Transformations - Graphing, Rules, Tricks - Cuemath
Transformation of functions means that the curve representing the graph either "moves to left/right/up/down" or "it expands or compresses" or "it reflects".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found