Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6863391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:46:36+00:00 2026-05-27T02:46:36+00:00

Set A has n devices. Set B has m devices. Some devices in A

  • 0

Set A has n devices. Set B has m devices. Some devices in A are compatible with the devices in B, and some devices in B are compatible with those in A.

I want as many compatible devices connected to each other as possible. (It’s not necessary to have the device a in A and b in B to be mutually compatible.)

Edit for clarity: any device can be linked to 0, 1 or 2 other devices, but not itself.

Eventually all devices (or all but two, if the “ends” don’t meet) should be linked together 1 on 1. It’s possible to link any one device to any other device. But no device in A are compatible with any device in A (but they are linkable), and the same holds true for devices in B.

If I have A = {a1,a2,a3}, B = {b1,b2,b3} and n=m=3

a1 is compatible with b1,b2
a2 is compatible with b1
a3 is compatible with b1
b1 is compatible with a1,a3
b2 is compatible with a1
b3 is compatible with a1

Then the graph G

a1 <-> b2 <-> a2 <-> b1 <-> a3 <-> b3 <-> a1

is an optimal graph.

G doesn’t have to be cyclic, but it can be.

Are there any clever ways to approach this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:46:37+00:00Added an answer on May 27, 2026 at 2:46 am

    I believe that this problem is NP-hard by a reduction from undirected longest path problem, which is known to be NP-hard by a reduction from the undirected Hamiltonian path problem (see Sipser’s Introduction to the Theory of Computation for details on why).

    In the undirected longest path problem, we are given as input an undirected graph G = (V, E), along with a pair of nodes u and v and some number k, and want to determine whether or not there is a simple (no node appears twice) path from u to v of length at least k. We can convert this into your problem using a polynomial-time reduction as follows:

    • For each node vi ∈ V, there is a device in A (call it di).
    • For each edge {vi, vj} ∈ V, there is a device in B (call it ei, j).
    • For each node vi and edge {vi, vj}, device di is compatible with device ei, j.

    This reduction has polynomial size, since the total number of devices generated is of size |V| + |E| and the number of connections is 2|E|. Moreover, we can see that there is a path of length k from vi to vj in graph G iff there is a chain of devices of length 2k + 1 from di to dj. Specifically, if ((vi1, vi2), (vi2, vi3), …, (vik – 1, vik)) is a simple path from vi to vj, then the chain di1 → ei1, i2 → di2 → ei2, i3 → di3 → … → eik – 1, ik → dik and vice-versa. We thus have a polynomial-time reduction from undirected longest path to you problem as follows:

    • Given as input (G, vi, vj, k) to the undirected longest path problem:
      • Construct the sets A and B as above, with compatibilities C as above.
      • Check whether there is a chain of devices of length 2k + 1 from di to dj.
      • If so, output “yes”
      • If not, output “no.”

    This reduction solves the undirected longest path problem in nondeterministic polynomial time using a solver for your problem, and so your problem is NP-hard. As a result, you should not expect to find a polynomial-time algorithm for your problem; finding an exact answer is likely to take exponential time unless P = NP.

    Sorry to give a negative answer, but I hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a txt file and each line has a set of random strings,
I have a customer that has set up a full backup of the database
i have follow taxomony has been set up: accommodation -backpacker -guest -holiday and i
I have a project which has a set of binary dependencies (assembly dlls for
We have an Access DB which has a set of local tables and input
I have a flash player that has a set of songs loaded via an
I'm doing some work making a Java app compatible with alternative input devices. Unfortunately,
I have a custom UITableViewCell which has some subviews. i.e. some labels, some images.
I have an UIViewController that has two UIViews inside, whose layout (set in Interface
How can I find the font that the user has set in their Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.