Network visualization from an edge table

I am new to KNIME and hitting a wall when trying to perform what should be a simple task:

In the process of reconstructing a network from time series data, I obtain an edge table: | source | target | weight |, which I want to visualize. Edges with negative and positive weights should be colored differently.

Looking at various options, it appears that I have to jump through many, many hoops to be able to do this in v. 5.5, without using Python or Java script nodes. Is there a straightforward way to do this using only KNIME/KNIME extension nodes?

Any help or hints for possible simple solutions will be much appreciated! Thanks.

Raina

Hi Raina,

welcome to our forum.

For this kind of plotting I highly recommend to use the Generic ECharts.

Here is an example:

Andreas

1 Like

Many thanks for this, Andreas! Much appreciated and cleaner than what I had. It still feels however that KNIME requires too many steps for such a simple task, although I guess this same approach is what makes it work so well for other projects :slight_smile:

Raina

Hi,

you have the right impression, that my solution had quite a lot of steps. This was due to my too complex approach regrading the input data shape of the Generic ECharts View.

Now I asked K-AI again and voilá no further steps are needed:

With following Code in the View:

// Hole die Daten aus der Tabelle
const rows = await inputTable.getData(["Start", "Ende", "Weight"]);

// Erstelle die Knotenliste (einzigartige Namen aus Start und Ende)
const nodeSet = new Set();
rows.forEach(([start, end]) => {
  nodeSet.add(start);
  nodeSet.add(end);
});
const nodes = Array.from(nodeSet).map(name => ({ name }));

// Erstelle die Kantenliste
const links = rows.map(([start, end, value]) => ({
  source: start,
  target: end,
  value,
  lineStyle: {
    color: value > 0 ? '#1E90FF' : (value < 0 ? '#FF4500' : 'gray'),
    width: Math.max(1, Math.abs(value))
  }
}));

option = {
  tooltip: {
    trigger: 'item',
    formatter: params => {
      if (params.dataType === 'edge') {
        return `${params.data.source} → ${params.data.target}<br>Value: ${params.data.value}`;
      }
      return params.data.name;
    }
  },
  series: [{
    type: 'graph',
    layout: 'force',
    roam: true,
    data: nodes,
    links: links,
    edgeSymbol: ['circle', 'arrow'],
    label: { show: true },
    lineStyle: {
      color: 'auto'
    },
    emphasis: { focus: 'adjacency' }
  }]
};

Andreas

2 Likes

Great, thanks! Much shorter! :slight_smile: Most importantly, you point me in the direction of using the assistance of K-AI, which I should have tried myself earlier. Having tested it now, it seem to work very well indeed in handling KNIME questions (unlike, say, Chat GPT – I just tried it for comparison and it was helpless). This makes me think I could use the platform in courses where students have little to no programming experience, and they rely on K-AI to do more complex scripting that would simplify their workflow. Thanks again.

Raina

3 Likes

It’s a pleasure.

I just can highly recommend KNIME and K-AI for the situations you described.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.