O algoritmo de Dijkstra é uma solução apropriada para esse problema de roteamento de sinal?

12

Estou desenvolvendo um módulo de gerenciamento e roteamento de sinais para um sistema audiovisual integrado e estou projetando-o com a intenção de ser o mais flexível possível em diferentes redes de distribuição de sinais. A intenção do módulo é manipular o roteamento entre vários comutadores de matriz empilhados 1 e manipular a conversão de formato necessária.

A melhor solução que eu explorei neste momento é mapear a rede para um gráfico com vértices discretos para cada tipo de sinal suportado pelos comutadores e que são então unidos por nós que representam os processadores de vídeo que manipulam a conversão de formato.

Exemplo de gráfico

Cores representam formatos de sinal. Nós redondos são comutadores, fontes ou sumidouros. Nós quadrados são processadores de vídeo que realizam conversão de formato.

A partir daí, posso usar uma implementação do algoritmo de Dijkstra para identificar o caminho que deve ser formado para obter a entrada X na saída Y. Isso deve permitir que os dados sobre a configuração de entrada / saída de todos os comutadores e processadores sejam transmitidos e o módulo se adapta de acordo.

Essa é uma solução apropriada ou existe uma abordagem alternativa que talvez valha a pena investigar?

1 aka 'crossbar switch', um roteador de vídeo com saídas M x N de entrada que suporta conexões um para muitos. Cada dispositivo físico pode lidar com vários formatos de sinal e pode ou não ser capaz de executar qualquer conversão de formato.

edit: Como mencionado por Péter Török, o gráfico não será necessariamente uma árvore, o diagrama é um exemplo simples para ilustrar a ideia. Quando implementados no 'mundo real', vários caminhos podem existir, oferecendo níveis variados de definição (DVI> VGA> componente> composto) que eu planejava representar com ponderação de borda.

edit 2: Here's an slightly more comprehensive example with directivity indicated and showing a network consisting of two signal types. The initial example has been modified slightly so that each input and output on a device is defined as a discrete node as this will provide the data required to control matrix routing / input selection. Exemplo 2 - dois tipos de sinal, comutadores empilhados

Kim Burgess
fonte
Are you intending edge weightings to be multiplicative?
Peter Taylor
Additive. The theory being this will allow it to be defined such that the higher the definition of the signal path, the lower the weighting. Edges which connect nodes that perform format conversion would then be given a weighting higher than that assigned to edges which connect non-conversion nodes. This would route the signal in it's native format if possible, only involving format conversion (and associated signal degradation and equipment utilisation) when necessary.
Kim Burgess
1
@PeterTaylor: Would it matter if they were multiplicative? They have exact same semantics as additive (provided they are positive) by applying a logarithm. Or is it something more complicated behind it?
herby
@herby, good point, hadn't thought of that. hangs head in shame
Peter Taylor

Respostas:

4

This is a tree, Dijkstra is O(n^2) overkill. Trivial O(n) breadth-first search is enough.

EDIT: Start the BFS in any node with degree at least two.

EDIT2: Since the graph is not guaranteed to be a tree, use Dijkstra, if you want to optimize a little, you can first "strip" the graph all the vertices of degree one (for them, the path is trivial), including those that happen to acquire degree one due to stripping their ex-neighbours, and do the Dijkstra on the rest (which is exactly the "non-tree" part).

Plus, I would say you want paths from every node to every other, don't you? Dijsktra's algorithm does only paths from one to all others. Maybe do Floyd-Warshall algorithm on the stripped rest. Of course, if the topology is very dynamic, it is best to do the (stripping and) Dijkstra, ad hoc.

herby
fonte
2
I believe the graph displayed above is a simpl(ified) example and in real life there may often be multiple alternative paths between two nodes (formats), i.e. you may not count on the graph always being a tree.
Péter Török
Suitably implemented, Dijkstra's algorithm would be O(n) too, although more complicated and still overkill.
Peter Taylor
@PéterTörök: In that case, yes. Only the asker knows for sure. But when it is a tree, bfs is enough (and dead simple).
herby
@PeterTaylor: Interesting. Any source, please?
herby
@PéterTörök is correct. See edited question.
Kim Burgess
2

You may be able to use A* (the more general form of Dijkstra's algorithm) for searching the graph in question. You mention the costs of the weightings in your comment:

Additive. The theory being this will allow it to be defined such that the higher the definition of the signal path, the lower the weighting. Edges which connect nodes that perform format conversion would then be given a weighting higher than that assigned to edges which connect non-conversion nodes. This would route the signal in it's native format if possible, only involving format conversion (and associated signal degradation and equipment utilisation) when necessary

If I understand it correctly, you want to find the lowest cost path path from the start to the goal. If you provide each node both an actual cost and an estimate (heuristic) to the goal (that is both admissible and consistent), then A* is guaranteed to provide an optimal solution. It might be overkill though, depending on how well I understand your problem.

jdt141
fonte
+1: As well, IIRC, the heuristic has to always estimate a cost that is worse than the actual cost in order for it to guarantee an optimal path. In the worst case, if you can't get the heuristic right, just return 0 from the heuristic and you've got dijkstra's algorithm.
Steven Evers