B
B
blabs2016-02-19 18:15:25
PHP
blabs, 2016-02-19 18:15:25

How to organize the algorithm of barter chains?

We are working on a service that allows you to exchange goods and services. Already several tens of thousands of registered users. who created profiles( City, Specialization, Information about myself), indicated their capabilities( I can ... , Description, Category( chose from the list), created deals( I need ... , Description, Category, Me on ... (indicated the possibilities))
How can barter chains be built on the basis of this?For example, in order for 3-5 users to participate in barter.Are there any thoughts on algorithms?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nirvimel, 2016-02-19
@nirvimel

Your data structure is called a directed graph. The vertices of the graph are contractors. Directed edges - situations when counterparty A offers a product that counterparty B wants to purchase (a query for selecting such situations is written in SQL elementary and is processed almost instantly if the correct indexes are available).
You have two tasks:

  1. Finding cycles in a directed graph (ideal). Ready-made solutions exist .
  2. Finding the longest path in a directed graph. Some suitable algorithms can also be found .

P
Peter, 2016-02-19
@petermzg

"I can..." is the result
. "I need to..." is a requirement.
Make a selection of "result" - "requirement", where it is described by a specific word.
Example:
butter - milk
milk - hay
hay - diesel
fuel Run through the selection a couple of times, here are the chains.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question