Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 13th, 2007, 09:57 AM
zeid zeid is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 57 zeid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 18 m 15 sec
Reputation Power: 3
Arrow Transitive relation

Hi all,

I need to do a program for my Discrete math class.

Main idea

Program should have 2 textboxes .. one to enter the domain such as "1 2 3 4 5" (This syntax) and the second one to enter a set of relations as this syntax "(1,1) (2,2) (3,1)"

Then When user clicks on the "Find properties" button, I should show him (in labels) each property such as:

IF reflexive or not
IF symmetric or not
IF anti symmetric or not
IF transitive or not

I have done the first 3 functions (properties) and i couldn't do the last one "Transitive".

Transitive is if there was (1,2) AND (2,3) Then there should be (1,3) in the entered set.

------------------------------------------

This is the first procedure to do it:

Code:
string2 = txt_relations.Text
string2 = Trim(string2)
array2 = Split(string2, " ", -1, vbTextCompare)


Now if user enteres (1,2) (2,3) (1,3) so:

array2(0) = "(1,2)"
array2(1) = "(2,3)"
array2(2) = "(1,3)"

And i did something like:

Code:
string2 = Replace(string2, "(", "")
string2 = Replace(string2, ")", "")
string2 = Replace(string2, ",", " ")
string2 = Trim(string2)

array3 = Split(string2, " ", -1, vbTextCompare)


So array3 have:

array3(0) = 1
array3(1) = 2
array3(2) = 2
array3(3) = 3
array3(4) = 1
array3(5) = 3

These are some ideas i thought but I couldn't complete it, also I thought about comparing array2 and string2 (before removing braces) and do some operations on them such as Instr etc...

For example

This what I did to say wether the relation is reflexive or not (Reflexive means if the domain was 1 2 3 then the relations should contain (1,1) (2,2) (3,3)"

Code:
Function CheckIsR(ByVal array1, ByVal array2)
Dim i As Integer
Dim TempString1 As String
Dim TempString2 As String
Dim TempArray
Dim counter
counter = 0

'MADE SOMETHING LIKE (1,1) (2,2) OR (A,A) (B,B) FROM THE DOMAIN ELEMENTS
For i = 0 To UBound(array1)
    If TempString1 = "" Then
        TempString1 = "(" + array1(i) + "," + array1(i) + ")"
    Else
        TempString1 = TempString1 + " " + "(" + array1(i) + "," + array1(i) + ")"
    End If
Next i

'MADE IT AS ARRAY EACH NEW RELATION AS AN ARRAY ELEMENT
TempArray = Split(TempString1, " ", -1, vbTextCompare)

'MADE A STRING FROM THE RELATIONS (THE ORIGINAL RELATIONS ENTERED BY USER)
For i = 0 To UBound(array2)
    If TempString2 = "" Then
        TempString2 = array2(i)
    Else
        TempString2 = TempString2 + " " + array2(i)
    End If
Next i

'CHECK IF THE NEW RELATIONS SUCH AS (1,1) (2,2) THAT ARE MADE FROM DOMAIN ARE FOUND IN THE RELATIONS STRING
'IF ONE OF THEM WAS NOT FOUND THEN COUNTER = COUNTER + 1

For i = 0 To UBound(TempArray)
    If InStr(1, TempString2, TempArray(i), vbTextCompare) = 0 Then
        counter = counter + 1
    Else
    
        'SKIP ONLY (OR DO NOTHING)
        lbl_skip.Caption = ""
    End If
Next i

'IF COUNTER IS EQUAL TO ZERO THEN IT'S REFLEXIVE, ELSE IT'S NOT REFLEXIVE
If counter = 0 Then
    CheckIsR = True
Else
    CheckIsR = False
End If
End Function


I really need to do this, I hope someone can help me,

Thanks in advance,
zeid

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Transitive relation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT