Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-stable
Commits
3a544ce9
Commit
3a544ce9
authored
Aug 20, 2007
by
Pramod R Sanaga
Browse files
some more changes to the equivalence classes part of the code.
parent
9c625309
Changes
1
Show whitespace changes
Inline
Side-by-side
pelab/bw-bottleneck/sharedBottle.pl
View file @
3a544ce9
...
@@ -337,6 +337,52 @@ foreach $sourceName (readdir(logsDirHandle))
...
@@ -337,6 +337,52 @@ foreach $sourceName (readdir(logsDirHandle))
# the sources, try to find equivalence classes
# the sources, try to find equivalence classes
# from each source. Check to ensure that the
# from each source. Check to ensure that the
# transitive property is not being violated.
# transitive property is not being violated.
#############
$counter1
=
0
;
$counter2
=
0
;
my
@deletionFlagArray
=
();
foreach
$classVar1
(
@equivClasses
)
{
push
(
@deletionFlagArray
,
0
);
}
foreach
$classVar1
(
@equivClasses
)
{
$counter2
=
0
;
$intersectionFlag
=
0
;
foreach
$classVar2
(
@equivClasses
)
{
if
(
(
$deletionFlagArray
[
$counter1
]
!=
1
)
and
(
$deletionFlagArray
[
$counter2
]
!=
1
)
and
(
$counter1
!=
$counter2
)
)
{
$intersectionFlag
=
&checkIntersection
(
$counter1
,
$counter2
);
if
(
$intersectionFlag
)
{
&mergeClasses
(
$counter1
,
$counter2
);
#Mark the equivalence class $counter2 for deletion.
$deletionFlagArray
[
$counter2
]
=
1
;
}
}
$counter2
+=
1
;
}
$counter1
+=
1
;
}
my
@tmpEquivClasses
=
@equivClasses
;
@equivClasses
=
();
$counter1
=
0
;
foreach
$classIter
(
@tmpEquivClasses
)
{
if
(
$deletionFlagArray
[
$counter1
]
==
0
)
{
push
(
@equivClasses
,
[
@$classIter
]);
}
$counter1
++
;
}
############
# For debugging.
# For debugging.
$retVal
=
&checkSanity
(
@equivClasses
,
@adjMatrix
);
$retVal
=
&checkSanity
(
@equivClasses
,
@adjMatrix
);
...
@@ -470,3 +516,46 @@ sub checkSanity()
...
@@ -470,3 +516,46 @@ sub checkSanity()
return
$retVal
;
return
$retVal
;
}
}
sub
checkIntersection
()
{
(
$index1
,
$index2
)
=
@_
;
@array1
=
@
{
$equivClasses
[
$index1
]};
@array2
=
@
{
$equivClasses
[
$index2
]};
foreach
$arrayMember
(
@array1
)
{
foreach
$checkVal
(
@array2
)
{
if
(
$arrayMember
==
$checkVal
)
{
return
1
;
}
}
}
return
0
;
}
sub
mergeClasses
()
{
(
$index1
,
$index2
)
=
@_
;
@secondArray
=
@
{
$equivClasses
[
$index2
]
};
$intersectionFlag
=
0
;
foreach
$tmpVal
(
@secondArray
)
{
foreach
$arrayMember
(
@
{
$equivClasses
[
$index1
]
})
{
if
(
$arrayMember
==
$tmpVal
)
{
$intersectionFlag
=
1
;
last
;
}
}
if
(
$intersectionFlag
==
0
)
{
push
(
@
{
$equivClasses
[
$index1
]},
$tmpVal
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment