|
Message Closed
modified 5-Jan-18 2:47am.
|
|
|
|
|
Message Closed
modified 15-Jan-18 13:17pm.
|
|
|
|
|
Sorry ... I thought it was a tree.
And sorry for boring you.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Something like this seems to work:
public static IReadOnlyCollection<T> FindPath<T>(this IReadOnlyDictionary<T, IReadOnlyCollection<T>> nodes, T start, T target, IEqualityComparer<T> comparer = null)
{
if (nodes == null) throw new ArgumentNullException(nameof(nodes));
if (comparer == null) comparer = EqualityComparer<T>.Default;
var prefix = new List<T> { start };
return FindPathCore(start, prefix);
IReadOnlyCollection<T> FindPathCore(T current, IReadOnlyCollection<T> pathToCurrent)
{
if (comparer.Equals(current, target))
{
return pathToCurrent;
}
if (nodes.TryGetValue(current, out var connections))
{
foreach (T node in connections.Except(pathToCurrent))
{
var path = new List<T>(pathToCurrent);
path.Add(node);
var result = FindPathCore(node, path);
if (result != null) return result;
}
}
return null;
}
} Test:
var test5 = new Dictionary<string, IReadOnlyCollection<string>>
{
["a"] = new List<string> { "c", "d", "b" },
["b"] = new List<string> { "c", "f", "g", "e" },
["e"] = new List<string> { "g", "h", "k" },
["k"] = new List<string> { "b", "l" },
};
test5.FindPath("a", "d").Dump();
test5.FindPath("a", "f").Dump();
test5.FindPath("a", "k").Dump();
test5.FindPath("k", "x").Dump();
test5.FindPath("k", "g").Dump();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
@RichardDeeming
Thanks, Richard; I don't know how I missed seeing this post until now, but I look forward to studying your code !
cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
I'm developing an app on multiple PC's. Sometimes at the office, sometimes at home.
I keep having to go into the App.Config and commenting/uncommenting connection strings to point to the PC that I'm on that day.
Is there a better way to do this?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
The SQL instance names are different on each PC, so I have different connection strings
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
That's what I use it for: different connections strings for my Desktop and the WookieTab. Change in one place on each machine (when necessary, I did it when I changed the PC name for the desktop and found out how many different little apps I had accessing SQL the hard way) and it changes in all apps on that machine.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If it's SQL server on your home machine, you can set up an alias so that when it sees the instance name used at work, it actually points to your local instance. You can therefore use the same connection string on both machines.
You set this up using SQL configuration manager
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Environement.MachineName tells me "who" is running ... and I can build my connections strings (db; web server; web services) accordingly.
If it's one of my "development machines", the app will run in "developer mode" (when activated).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
hi, i'm rezki from Indonesia, i was a student at a university in Indonesia..
i use emgu cv to make a SURF program to image retrieval, and i have a list code like this :
Index fln = new Index(supermatrix, 4);
but then, it gives me an error like this :
Argument 2 : cannot convert from 'int' to 'Emgu.CV,Flann.IIndexparams
can you help me please..
i'm so stressfull to solving this error :'(
thank you so much.. and i'm sorry to take your time
|
|
|
|
|
The Index constructor does not take a simple integer values for the second parameter. See Index Constructor[^] for details.
|
|
|
|
|
|
It's telling you that you can't pass an integer in; instead, you have to pass in something that implements IIndexParams. The default implementations from Emgu are AutotunedIndexParams, CompositeIndexParams, HierarchicalClusteringIndexParams, KdTreeIndexParams, KMeansIndexParams, LinearIndexParams, LshIndexParams and SearchParams. You just need to choose the appropriate one (also, you need to learn how to read a build error; this was all clearly laid out).
This space for rent
|
|
|
|
|
Pete O'Hanlon wrote: also, you need to learn how to read a build error; this was all clearly laid out
Yes, but I remember in this galaxy long, long ago, when I was still a padawan, I also had trouble reading those d*mn build errors.
With time, one learns to understand the force and read build errors.
|
|
|
|
|
Hi, thank you so much for your solution 😄..
I will do that sir,thank you..
|
|
|
|
|
how 3tier application works.......??
|
|
|
|
|
|
You forgot the "presentation layer" (PAL?).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
yeah..!! Plz explain tat also..
|
|
|
|
|
I have 3 tables:
Companies
Company Contacts
Contacts
For a given company Id I want to pull all contacts:
var contacts = db.Contacts.Where(c => db.CompanyContacts
.Select(cc => cc.CompanyId)
.Contains(c.Id)).
Select(x => new ContactEntity
{
Id = x.Id,
Prefix = x.Prefix,
FirstName = x.FirstName,
MiddleName = x.MiddleName,
LastName = x.LastName,
Suffix = x.Sufffix
});
This is returning ALL contacts, not just the contacts for the companyId passed in.
What's the right way to do this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You need to set the variable value of the company ID to your where clause. Here's a quick example using syntax-based query.
var companyId = 100;
var contacts = (from a in db.Company
join b in db.CompanyContacts on a.CompanyId equals b.CompanyId
join c in db.Contacts on b.ContactId equals c.ContactId
where a.CompanyId == companyId
select(x => new ContactEntity
{
Id = x.Id,
Prefix = x.Prefix,
FirstName = x.FirstName,
MiddleName = x.MiddleName,
LastName = x.LastName,
Suffix = x.Sufffix
}));
modified 4-Jan-18 2:05am.
|
|
|
|
|
Hi everybody,
I have an image which displays the state of execution of an action.
- green: the execution is currently performed
- yellow: the execution has been interrupted
- red: an error has occurred
- green: the execution is complete and went fine.
The problem:
I would like to make this image blinking (green) as long as the current action is executed.
Has anyone an idea on how to proceed?
|
|
|
|
|
Sounds like an ideal candidate to run as an animation[^].
This space for rent
|
|
|
|