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 8755291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:49:36+00:00 2026-06-13T13:49:36+00:00

Is there an algorithm (or a sequence of algorithms) to find, given a generic

  • 0

Is there an algorithm (or a sequence of algorithms) to find, given a generic graph structure G=(V,E) with no notion of parent node, leaf node and child node but only neighboordhood relations:

1) If G it is a tree or not (is it sufficient to check |V| = |E|+1?)

2) If the graph is actually a tree, the leaves and the center of it? (i.e the node of the graph which minimizes the tree depth)

Thanks

  • 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-06-13T13:49:38+00:00Added an answer on June 13, 2026 at 1:49 pm

    If the “center” of the tree is defined as “the node of the graph which minimizes the tree depth”, there’s an easier way to find it than finding the diameter.

    d[] = degrees of all nodes
    que = { leaves, i.e  i that d[i]==1}
    while len(que) > 1:
      i=que.pop_front
      d[i]--
      for j in neighbors[i]:
        if d[j] > 0:
          d[j]--
          if d[j] == 1 :
            que.push_back(j)
    

    and the last one left in que is the center.

    you can prove this by thinking about the diameter path.
    to simpify , we assume the length of the diameter path is odd, so that the middle node of the path is unique, let’s call that node M,

    we can see that:

    1. M will not be pushed to the back of que until every node else on
      diameter path has been pushed into que
    2. if there’s another node N
      that is pushed after M has already been pushed into que, then N must
      be on a longer path than the diameter path. Therefore N can’t exist. M must be the last
      node pushed (and left) in que
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any algorithm that gives the compass direction of a shadow given latitude,
Is there an algorithm to split a sequence of random numbers into two groups
Is there an STL algorithm which can be used to search a sequence of
Given a sequence of number which can be positive and negative, there are several
Is there an algorithm to estimate the median, mode, skewness, and/or kurtosis of set
Is there an algorithm for figuring out the following things? If the result of
Is there an algorithm to securely split a message into x parts requiring at
Is there any algorithm in c# to singularize - pluralize a word (in english)
Is there a preferred algorithm for converting a 2-digit year into a 4-digit year?
Is there an existing algorithm for converting a quaternion representation of a rotation to

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.